Skip to content

Commit afa141e

Browse files
committed
Refactor paths and remove unused dependencies
Updated file path logic to use `Configuration` for clarity and consistency. Removed unused Fody and Costura dependencies, simplifying the project setup. Minor formatting adjustments for better readability and maintainability.
1 parent 4e23fe9 commit afa141e

File tree

4 files changed

+40
-35
lines changed

4 files changed

+40
-35
lines changed

source/DictionariesProvider/DictionariesProvider.csproj

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,11 @@
1010
<Reference Include="System.Net.Http"/>
1111
</ItemGroup>
1212
<ItemGroup>
13-
<PackageReference Include="Costura.Fody">
14-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15-
<PrivateAssets>all</PrivateAssets>
16-
</PackageReference>
17-
<PackageReference Include="Fody">
18-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19-
<PrivateAssets>all</PrivateAssets>
20-
</PackageReference>
21-
<PackageReference Include="Newtonsoft.Json"/>
13+
<PackageReference Include="libse" />
14+
<PackageReference Include="Newtonsoft.Json" IncludeAssets="compile"/>
2215
</ItemGroup>
2316
<PropertyGroup>
2417
<!-- <PostBuildEvent Condition="$(SE_Plugin) != ''">xcopy /s /y $(TargetDir)*.* "$(SE_Plugin)"</PostBuildEvent>-->
2518
</PropertyGroup>
26-
<Import Project="..\Plugin-Shared\Plugin-Shared.projitems" Label="Shared"/>
19+
<!-- <Import Project="..\Plugin-Shared\Plugin-Shared.projitems" Label="Shared"/>-->
2720
</Project>

source/DictionariesProvider/EntryPoint.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ public class DictionariesProvider : IPlugin
1212

1313
public decimal Version => 1m;
1414

15-
public string Description => "Download and install dictionaries";
15+
public string Description => "Download and install dictionaries (by Ivandrofly)";
1616

1717
public string ActionType => "spellcheck";
1818

1919
public string Shortcut => string.Empty;
2020

2121
public string DoAction(Form parentForm, string srtText, double frameRate, string uiLineBreak, string file, string videoFile, string rawText)
2222
{
23-
AppDomain.CurrentDomain.AssemblyResolve += AssemblyUtils.CurrentDomainAssemblyResolve;
23+
// AppDomain.CurrentDomain.AssemblyResolve += AssemblyUtils.CurrentDomainAssemblyResolve;
2424

2525
using (var mainForm = new Main())
2626
{
@@ -31,6 +31,16 @@ public string DoAction(Form parentForm, string srtText, double frameRate, string
3131

3232
return string.Empty;
3333
}
34+
}
3435

36+
public interface IPlugin
37+
{
38+
string Name { get; }
39+
string Text { get; }
40+
decimal Version { get; }
41+
string Description { get; }
42+
string ActionType { get; }
43+
string Shortcut { get; }
44+
string DoAction(Form parentForm, string srtText, double frameRate, string uiLineBreak, string file, string videoFile, string rawText);
3545
}
36-
}
46+
}

source/DictionariesProvider/Forms/Main.cs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Windows.Forms;
1010
using System.Xml.Linq;
1111
using Newtonsoft.Json;
12+
using Nikse.SubtitleEdit.Core.Common;
1213

1314
namespace Nikse.SubtitleEdit.PluginLogic.Forms
1415
{
@@ -19,7 +20,6 @@ public partial class Main : Form
1920

2021
private List<DictionaryInfo> DictionariesInfo { get; set; }
2122

22-
2323
public Main()
2424
{
2525
InitializeComponent();
@@ -63,7 +63,7 @@ public Main()
6363

6464
private void LoadConfigs()
6565
{
66-
string file = Path.Combine(FileUtils.Plugins, SettingFile);
66+
string file = Path.Combine(Configuration.PluginsDirectory, SettingFile);
6767
if (File.Exists(file))
6868
{
6969
string content = File.ReadAllText(file);
@@ -75,9 +75,10 @@ private void LoadConfigs()
7575
{
7676
// maybe the saving configuration changes
7777
File.Move(file, Path.GetDirectoryName(file) +
78-
Path.GetFileNameWithoutExtension(file) + ".old" + Path.GetExtension(file));
78+
Path.GetFileNameWithoutExtension(file) + ".old" + Path.GetExtension(file));
7979
DictionariesInfo = new List<DictionaryInfo>();
8080
}
81+
8182
UpdateListView();
8283
}
8384
else
@@ -120,7 +121,7 @@ private void ButtonAddDictionary_Click(object sender, EventArgs e)
120121
NativeName = textBoxNativeName.Text,
121122
Description = textBoxDescription.Text,
122123
DownloadLinks = comboBoxDownloadLinks.Items.Cast<string>()
123-
.Select(dl => new DownloadLink { Url = new Uri(dl) }).ToList()
124+
.Select(dl => new DownloadLink { Url = new Uri(dl) }).ToList()
124125
});
125126

126127
UpdateListView();
@@ -160,7 +161,7 @@ private void UpdateListView()
160161
private void ButtonOk_Click(object sender, EventArgs e)
161162
{
162163
var jsonString = JsonConvert.SerializeObject(DictionariesInfo, Formatting.Indented);
163-
string file = Path.Combine(FileUtils.Plugins, SettingFile);
164+
string file = Path.Combine(Configuration.PluginsDirectory, SettingFile);
164165
File.WriteAllText(file, jsonString);
165166
DialogResult = DialogResult.OK;
166167
}
@@ -195,32 +196,32 @@ private void ImportFormXMLToolStripMenuItem_Click(object sender, EventArgs e)
195196
var elDics = xdoc.Descendants("Dictionary");
196197

197198
DictionariesInfo = elDics.Select(el =>
198-
new DictionaryInfo
199-
{
200-
NativeName = el.Element("NativeName")?.Value,
201-
EnglishName = el.Element("EnglishName")?.Value,
202-
Description = el.Element("Description")?.Value,
203-
DownloadLinks = new List<DownloadLink>{
204-
new DownloadLink
205-
{
206-
Url = new Uri(el.Element("DownloadLink").Value),
207-
Status = true
208-
}
209-
}
210-
}).ToList();
199+
new DictionaryInfo
200+
{
201+
NativeName = el.Element("NativeName")?.Value,
202+
EnglishName = el.Element("EnglishName")?.Value,
203+
Description = el.Element("Description")?.Value,
204+
DownloadLinks = new List<DownloadLink>
205+
{
206+
new DownloadLink
207+
{
208+
Url = new Uri(el.Element("DownloadLink").Value),
209+
Status = true
210+
}
211+
}
212+
}).ToList();
211213

212214
UpdateListView();
213215
}
214-
215216
}
216217
}
217218

218219
private async void ButtonUpdateStatus_Click(object sender, EventArgs e)
219220
{
220221
buttonUpdateStatus.Enabled = false;
221222
//await System.Threading.Tasks.Task.Yield();
222-
await _webUtils.UpdateStateAsync(DictionariesInfo.SelectMany(di => di.DownloadLinks));//.ConfigureAwait(true);
223+
await _webUtils.UpdateStateAsync(DictionariesInfo.SelectMany(di => di.DownloadLinks)); //.ConfigureAwait(true);
223224
buttonUpdateStatus.Enabled = true;
224225
}
225226
}
226-
}
227+
}

source/DictionariesProvider/Helpers/WebUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Net.Http;
1010
using System.Threading;
1111
using System.Threading.Tasks;
12+
using Nikse.SubtitleEdit.Core.Common;
1213

1314
namespace Nikse.SubtitleEdit.PluginLogic.Helpers
1415
{
@@ -111,7 +112,7 @@ private async Task ExtraFile(Stream dicFile)
111112
continue;
112113
}
113114

114-
string output = Path.Combine(FileUtils.Dictionaries, entry.FullName);
115+
string output = Path.Combine(Configuration.DictionariesDirectory, entry.FullName);
115116

116117
try
117118
{

0 commit comments

Comments
 (0)