Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string DoAction(Form parentForm, string srtText, double frame, string uiLineBreak, string file,
- string videoFile, string rawText)
- {
- // HI2UC.dll
- // Solution: Works if this events is regstered in SubtitleEdit.exe e.g: in method that loads the plugins
- AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
- {
- var assemblyName = new AssemblyName(args.Name);
- Debug.WriteLine($"Loading assembly {assemblyName.Name}");
- // Assembly.GetExecutingAssembly().Location
- // IMPORTANT: Assembly.GetExecutingAssembly().Location == string.empty because the assembly are read as by and then loaded in SubtitleEdit:Main.cs
- var assemblyFile = Path.Combine(Assembly.GetExecutingAssembly().Location,
- "libs", assemblyName.Name + ".dll");
- if (File.Exists(assemblyFile))
- {
- Debug.WriteLine($"Assembly {assemblyName.Name} found at {assemblyFile}");
- return Assembly.LoadFile(assemblyFile);
- }
- return null;
- };
- #if DEBUG
- /// <summary>
- /// Launch and attach a debugger to the process if it's not already attached.
- /// This is helpful when a need arises to debug code in the startup sequence of an application
- /// or to debug issues that occur when a debugger isn't already attached.
- /// </summary>
- if (!Debugger.IsAttached)
- {
- Debugger.Launch();
- }
- #endif
- // Make sure subtitle isn't null or empty
- if (string.IsNullOrWhiteSpace(srtText))
- {
- MessageBox.Show("No subtitle loaded", parentForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return string.Empty;
- }
- // Use custom separator for list view new lines
- if (!string.IsNullOrEmpty(uiLineBreak))
- {
- Options.UILineBreak = uiLineBreak;
- }
- // Get subtitle raw lines
- var list = new List<string>(srtText.SplitToLines());
- var srt = new SubRip();
- var sub = new Subtitle(srt);
- // Load raws subtitle lines into Subtitle object
- srt.LoadSubtitle(sub, list, file);
- IPlugin hi2Uc = this;
- using (var form = new PluginForm(sub, hi2Uc.Name, hi2Uc.Description))
- {
- if (form.ShowDialog(parentForm) == DialogResult.OK)
- {
- return form.Subtitle;
- }
- }
- return string.Empty;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement