├── .gitignore ├── DesktopLyrics.cs ├── DesktopLyrics.csproj ├── DesktopLyrics.sln ├── FodyWeavers.xml ├── FodyWeavers.xsd ├── FontConverter.cs ├── FrmLyrics.Designer.cs ├── FrmLyrics.cs ├── FrmLyrics.resx ├── FrmSettings.Designer.cs ├── FrmSettings.cs ├── FrmSettings.resx ├── Gdiplus.cs ├── GdiplusPInvoke.cs ├── LICENSE ├── LyricParser.cs ├── LyricsController.cs ├── LyricsRenderer.cs ├── MusicBeeInterface.cs ├── Properties └── AssemblyInfo.cs ├── README.md ├── UnmanagedHelper.cs ├── app.config └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | pkg/ 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | bld/ 24 | [Bb]in/ 25 | [Oo]bj/ 26 | [Ll]og/ 27 | 28 | # Visual Studio 2015/2017 cache/options directory 29 | .vs/ 30 | # Uncomment if you have tasks that create the project's static files in wwwroot 31 | #wwwroot/ 32 | 33 | # Visual Studio 2017 auto generated files 34 | Generated\ Files/ 35 | 36 | # MSTest test Results 37 | [Tt]est[Rr]esult*/ 38 | [Bb]uild[Ll]og.* 39 | 40 | # NUNIT 41 | *.VisualState.xml 42 | TestResult.xml 43 | 44 | # Build Results of an ATL Project 45 | [Dd]ebugPS/ 46 | [Rr]eleasePS/ 47 | dlldata.c 48 | 49 | # Benchmark Results 50 | BenchmarkDotNet.Artifacts/ 51 | 52 | # .NET Core 53 | project.lock.json 54 | project.fragment.lock.json 55 | artifacts/ 56 | **/Properties/launchSettings.json 57 | 58 | # StyleCop 59 | StyleCopReport.xml 60 | 61 | # Files built by Visual Studio 62 | *_i.c 63 | *_p.c 64 | *_i.h 65 | *.ilk 66 | *.meta 67 | *.obj 68 | *.iobj 69 | *.pch 70 | *.pdb 71 | *.ipdb 72 | *.pgc 73 | *.pgd 74 | *.rsp 75 | *.sbr 76 | *.tlb 77 | *.tli 78 | *.tlh 79 | *.tmp 80 | *.tmp_proj 81 | *.log 82 | *.vspscc 83 | *.vssscc 84 | .builds 85 | *.pidb 86 | *.svclog 87 | *.scc 88 | 89 | # Chutzpah Test files 90 | _Chutzpah* 91 | 92 | # Visual C++ cache files 93 | ipch/ 94 | *.aps 95 | *.ncb 96 | *.opendb 97 | *.opensdf 98 | *.sdf 99 | *.cachefile 100 | *.VC.db 101 | *.VC.VC.opendb 102 | 103 | # Visual Studio profiler 104 | *.psess 105 | *.vsp 106 | *.vspx 107 | *.sap 108 | 109 | # Visual Studio Trace Files 110 | *.e2e 111 | 112 | # TFS 2012 Local Workspace 113 | $tf/ 114 | 115 | # Guidance Automation Toolkit 116 | *.gpState 117 | 118 | # ReSharper is a .NET coding add-in 119 | _ReSharper*/ 120 | *.[Rr]e[Ss]harper 121 | *.DotSettings.user 122 | 123 | # JustCode is a .NET coding add-in 124 | .JustCode 125 | 126 | # TeamCity is a build add-in 127 | _TeamCity* 128 | 129 | # DotCover is a Code Coverage Tool 130 | *.dotCover 131 | 132 | # AxoCover is a Code Coverage Tool 133 | .axoCover/* 134 | !.axoCover/settings.json 135 | 136 | # Visual Studio code coverage results 137 | *.coverage 138 | *.coveragexml 139 | 140 | # NCrunch 141 | _NCrunch_* 142 | .*crunch*.local.xml 143 | nCrunchTemp_* 144 | 145 | # MightyMoose 146 | *.mm.* 147 | AutoTest.Net/ 148 | 149 | # Web workbench (sass) 150 | .sass-cache/ 151 | 152 | # Installshield output folder 153 | [Ee]xpress/ 154 | 155 | # DocProject is a documentation generator add-in 156 | DocProject/buildhelp/ 157 | DocProject/Help/*.HxT 158 | DocProject/Help/*.HxC 159 | DocProject/Help/*.hhc 160 | DocProject/Help/*.hhk 161 | DocProject/Help/*.hhp 162 | DocProject/Help/Html2 163 | DocProject/Help/html 164 | 165 | # Click-Once directory 166 | publish/ 167 | 168 | # Publish Web Output 169 | *.[Pp]ublish.xml 170 | *.azurePubxml 171 | # Note: Comment the next line if you want to checkin your web deploy settings, 172 | # but database connection strings (with potential passwords) will be unencrypted 173 | *.pubxml 174 | *.publishproj 175 | 176 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 177 | # checkin your Azure Web App publish settings, but sensitive information contained 178 | # in these scripts will be unencrypted 179 | PublishScripts/ 180 | 181 | # NuGet Packages 182 | *.nupkg 183 | # The packages folder can be ignored because of Package Restore 184 | **/[Pp]ackages/* 185 | # except build/, which is used as an MSBuild target. 186 | !**/[Pp]ackages/build/ 187 | # Uncomment if necessary however generally it will be regenerated when needed 188 | #!**/[Pp]ackages/repositories.config 189 | # NuGet v3's project.json files produces more ignorable files 190 | *.nuget.props 191 | *.nuget.targets 192 | 193 | # Microsoft Azure Build Output 194 | csx/ 195 | *.build.csdef 196 | 197 | # Microsoft Azure Emulator 198 | ecf/ 199 | rcf/ 200 | 201 | # Windows Store app package directories and files 202 | AppPackages/ 203 | BundleArtifacts/ 204 | Package.StoreAssociation.xml 205 | _pkginfo.txt 206 | *.appx 207 | 208 | # Visual Studio cache files 209 | # files ending in .cache can be ignored 210 | *.[Cc]ache 211 | # but keep track of directories ending in .cache 212 | !*.[Cc]ache/ 213 | 214 | # Others 215 | ClientBin/ 216 | ~$* 217 | *~ 218 | *.dbmdl 219 | *.dbproj.schemaview 220 | *.jfm 221 | *.pfx 222 | *.publishsettings 223 | orleans.codegen.cs 224 | 225 | # Including strong name files can present a security risk 226 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 227 | #*.snk 228 | 229 | # Since there are multiple workflows, uncomment next line to ignore bower_components 230 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 231 | #bower_components/ 232 | 233 | # RIA/Silverlight projects 234 | Generated_Code/ 235 | 236 | # Backup & report files from converting an old project file 237 | # to a newer Visual Studio version. Backup files are not needed, 238 | # because we have git ;-) 239 | _UpgradeReport_Files/ 240 | Backup*/ 241 | UpgradeLog*.XML 242 | UpgradeLog*.htm 243 | ServiceFabricBackup/ 244 | *.rptproj.bak 245 | 246 | # SQL Server files 247 | *.mdf 248 | *.ldf 249 | *.ndf 250 | 251 | # Business Intelligence projects 252 | *.rdl.data 253 | *.bim.layout 254 | *.bim_*.settings 255 | *.rptproj.rsuser 256 | 257 | # Microsoft Fakes 258 | FakesAssemblies/ 259 | 260 | # GhostDoc plugin setting file 261 | *.GhostDoc.xml 262 | 263 | # Node.js Tools for Visual Studio 264 | .ntvs_analysis.dat 265 | node_modules/ 266 | 267 | # Visual Studio 6 build log 268 | *.plg 269 | 270 | # Visual Studio 6 workspace options file 271 | *.opt 272 | 273 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 274 | *.vbw 275 | 276 | # Visual Studio LightSwitch build output 277 | **/*.HTMLClient/GeneratedArtifacts 278 | **/*.DesktopClient/GeneratedArtifacts 279 | **/*.DesktopClient/ModelManifest.xml 280 | **/*.Server/GeneratedArtifacts 281 | **/*.Server/ModelManifest.xml 282 | _Pvt_Extensions 283 | 284 | # Paket dependency manager 285 | .paket/paket.exe 286 | paket-files/ 287 | 288 | # FAKE - F# Make 289 | .fake/ 290 | 291 | # JetBrains Rider 292 | .idea/ 293 | *.sln.iml 294 | 295 | # CodeRush 296 | .cr/ 297 | 298 | # Python Tools for Visual Studio (PTVS) 299 | __pycache__/ 300 | *.pyc 301 | 302 | # Cake - Uncomment if you are using it 303 | # tools/** 304 | # !tools/packages.config 305 | 306 | # Tabs Studio 307 | *.tss 308 | 309 | # Telerik's JustMock configuration file 310 | *.jmconfig 311 | 312 | # BizTalk build output 313 | *.btp.cs 314 | *.btm.cs 315 | *.odx.cs 316 | *.xsd.cs 317 | 318 | # OpenCover UI analysis results 319 | OpenCover/ 320 | 321 | # Azure Stream Analytics local run output 322 | ASALocalRun/ 323 | 324 | # MSBuild Binary and Structured Log 325 | *.binlog 326 | 327 | # NVidia Nsight GPU debugger configuration file 328 | *.nvuser 329 | 330 | # MFractors (Xamarin productivity tool) working folder 331 | .mfractor/ 332 | -------------------------------------------------------------------------------- /DesktopLyrics.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Diagnostics.CodeAnalysis; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Reflection; 7 | using System.Timers; 8 | using System.Windows.Forms; 9 | using Newtonsoft.Json; 10 | using Exception = System.Exception; 11 | using Timer = System.Timers.Timer; 12 | 13 | namespace MusicBeePlugin 14 | { 15 | [SuppressMessage("ReSharper", "UnusedMember.Global")] 16 | // ReSharper disable once ClassNeverInstantiated.Global 17 | public partial class Plugin 18 | { 19 | private const long UpdateIntervalMs = 100L; 20 | private const string SettingsFileName = "desktopLyrics.json"; 21 | private const string SettingsFileName2 = "desktopLyrics_Window.set"; 22 | 23 | // MB related 24 | private MusicBeeApiInterface _mbApiInterface; 25 | private readonly PluginInfo _about = new PluginInfo(); 26 | private string SettingsPath => Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), SettingsFileName); 27 | private string SettingsPath2 => Path.Combine(_mbApiInterface.Setting_GetPersistentStoragePath(), SettingsFileName2); 28 | // Customed 29 | private volatile SettingsObj _settings; 30 | private volatile FrmLyrics _frmLyrics; 31 | private Timer _timer; 32 | private LyricsController _lyricsCtrl; 33 | private readonly object _lock = new object(); 34 | 35 | public PluginInfo Initialise(IntPtr apiInterfacePtr) 36 | { 37 | var versions = Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.'); 38 | 39 | _mbApiInterface = new MusicBeeApiInterface(); 40 | _mbApiInterface.Initialise(apiInterfacePtr); 41 | _about.PluginInfoVersion = PluginInfoVersion; 42 | _about.Name = "Desktop Lyrics"; 43 | _about.Description = "Display lyrics on your desktop!"; 44 | _about.Author = "Charlie Jiang"; 45 | _about.TargetApplication = ""; // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger 46 | _about.Type = PluginType.General; 47 | _about.VersionMajor = short.Parse(versions[0]); // your plugin version 48 | _about.VersionMinor = short.Parse(versions[1]); 49 | _about.Revision = short.Parse(versions[2]); 50 | _about.MinInterfaceVersion = MinInterfaceVersion; 51 | _about.MinApiRevision = MinApiRevision; 52 | _about.ReceiveNotifications = ReceiveNotificationFlags.PlayerEvents; 53 | _about.ConfigurationPanelHeight = 0; // height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function 54 | 55 | _lyricsCtrl = new LyricsController(_mbApiInterface); 56 | return _about; 57 | } 58 | 59 | // ReSharper disable once UnusedParameter.Global 60 | public bool Configure(IntPtr panelHandle) 61 | { 62 | var settingsForm = new FrmSettings(_settings); 63 | settingsForm.SettingsChanged += (sender, settings) => _frmLyrics.UpdateFromSettings(settings); 64 | settingsForm.ShowDialog(); 65 | SaveSettings(_settings); 66 | LyricParser.PreserveSlash = _settings.PreserveSlash; 67 | _lyricsCtrl.NextLineWhenNoTranslation = _settings.NextLineWhenNoTranslation; 68 | _frmLyrics?.Invoke(new Action(() => 69 | { 70 | _frmLyrics.UpdateFromSettings(_settings); 71 | })); 72 | return true; 73 | } 74 | 75 | private void SaveSettings(SettingsObj settings) 76 | { 77 | File.WriteAllText(SettingsPath, JsonConvert.SerializeObject(settings)); 78 | } 79 | 80 | public void SaveSettings() 81 | { 82 | // Still, we've saved all settings already. 83 | } 84 | 85 | // MusicBee is closing the plugin (plugin is being disabled by user or MusicBee is shutting down) 86 | // ReSharper disable once UnusedParameter.Global 87 | public void Close(PluginCloseReason reason) 88 | { 89 | _timer.Stop(); 90 | _frmLyrics?.Invoke(new Action(() => 91 | { 92 | _frmLyrics?.Hide(); 93 | _frmLyrics = null; 94 | })); 95 | SaveSettings(_settings); 96 | } 97 | 98 | public void Uninstall() 99 | { 100 | if (File.Exists(SettingsPath)) File.Delete(SettingsPath); 101 | if (File.Exists(SettingsPath2)) File.Delete(SettingsPath2); 102 | } 103 | 104 | // ReSharper disable once UnusedParameter.Global 105 | public void ReceiveNotification(string sourceFileUrl, NotificationType type) 106 | { 107 | // perform some action depending on the notification type 108 | // ReSharper disable once SwitchStatementMissingSomeCases 109 | switch (type) 110 | { 111 | case NotificationType.PluginStartup: 112 | // while (!Debugger.IsAttached) System.Threading.Thread.Sleep(1); 113 | try 114 | { 115 | try 116 | { 117 | _settings = JsonConvert.DeserializeObject(File.ReadAllText(SettingsPath)); 118 | } 119 | catch (Exception) 120 | { 121 | _settings = SettingsObj.GenerateDefault(); 122 | } 123 | 124 | Application.EnableVisualStyles(); 125 | Application.SetCompatibleTextRenderingDefault(false); 126 | 127 | StartupMenuItem(); 128 | if (!_settings.HideOnStartup) 129 | StartupForm(); 130 | 131 | if (_timer != null && _timer.Enabled) _timer.Enabled = false; 132 | _timer = new Timer(UpdateIntervalMs) {AutoReset = false}; 133 | _timer.Elapsed += TimerTick; 134 | _timer.Start(); 135 | } 136 | catch (Exception e) 137 | { 138 | _mbApiInterface.MB_Trace(e.ToString()); 139 | } 140 | break; 141 | case NotificationType.PlayStateChanged: 142 | UpdatePlayState(_mbApiInterface.Player_GetPlayState()); 143 | break; 144 | case NotificationType.NowPlayingLyricsReady: 145 | try 146 | { 147 | UpdateLyrics(force: true); 148 | } 149 | catch (Exception e) 150 | { 151 | _mbApiInterface.MB_Trace(e.ToString()); 152 | } 153 | break; 154 | case NotificationType.TagsChanged: 155 | try 156 | { 157 | UpdateLyrics(force: true); 158 | } 159 | catch (Exception e) 160 | { 161 | _mbApiInterface.MB_Trace(e.ToString()); 162 | } 163 | break; 164 | } 165 | } 166 | 167 | // Change form according to play state 168 | private void UpdatePlayState(PlayState state) 169 | { 170 | if (!_settings.AutoHide) return; 171 | if (_frmLyrics == null) return; 172 | switch (state) 173 | { 174 | case PlayState.Stopped: 175 | _frmLyrics.Visible = false; 176 | break; 177 | case PlayState.Playing: 178 | _frmLyrics.Visible = true; 179 | break; 180 | } 181 | } 182 | 183 | private void StartupMenuItem() 184 | { 185 | // MenuItem will only be returned before we construct the handler lambda expression, so we have to use a "slot" 186 | // (which will be filled after MB_AddMenuItem returns) to hold the menuItem to be referred in the closure. 187 | var menuItemSlot = new ToolStripMenuItem[] { null }; 188 | 189 | var menuItem = (ToolStripMenuItem) _mbApiInterface.MB_AddMenuItem( 190 | "mnuView/Desktop Lyrics", "Toggle Desktop Lyrics visibility.", 191 | ToggleLyrics); 192 | menuItemSlot[0] = menuItem; 193 | menuItem.Checked = !_settings.HideOnStartup; 194 | return; 195 | 196 | void ToggleLyrics(object sender, EventArgs args) 197 | { 198 | var menuItem2 = menuItemSlot[0]; 199 | if (menuItem2 == null) return; // BUG: multithread race condition 200 | 201 | menuItem2.Checked = !menuItem2.Checked; 202 | if (!menuItem2.Checked) 203 | _frmLyrics?.Dispose(); 204 | else 205 | StartupForm(); 206 | _settings.HideOnStartup = !menuItem2.Checked; 207 | SaveSettings(_settings); 208 | } 209 | } 210 | 211 | private void StartupForm() 212 | { 213 | _frmLyrics?.Dispose(); 214 | var f = (Form)Control.FromHandle(_mbApiInterface.MB_GetWindowHandle()); 215 | f.Invoke(new Action(() => 216 | { 217 | _frmLyrics = new FrmLyrics(_settings); 218 | _frmLyrics.Show(); 219 | try 220 | { 221 | UpdateLyrics(force: true); 222 | } 223 | catch (Exception e) 224 | { 225 | _mbApiInterface.MB_Trace(e.ToString()); 226 | } 227 | })); 228 | } 229 | 230 | private void TimerTick(object sender, ElapsedEventArgs args) 231 | { 232 | Debug.Assert(sender is Timer); 233 | try 234 | { 235 | UpdateLyrics(); 236 | } 237 | catch (Exception e) 238 | { 239 | _mbApiInterface.MB_Trace(e.ToString()); 240 | } 241 | ((Timer) sender).Start(); 242 | } 243 | 244 | private string _line1, _line2; 245 | private void UpdateLyrics(bool force = false) 246 | { 247 | lock (_lock) 248 | { 249 | if (_frmLyrics == null) return; 250 | var entry = _lyricsCtrl.UpdateLyrics(!_settings.HideWhenUnavailable); 251 | if (entry == null && _line1 != "") 252 | { 253 | _line1 = ""; 254 | _frmLyrics.Clear(); 255 | return; 256 | } 257 | 258 | if (entry == null) return; 259 | if (!force && entry.LyricLine1 == _line1 && entry.LyricLine2 == _line2) return; 260 | _frmLyrics.BeginInvoke(new Action((line1, line2) => _frmLyrics.UpdateLyrics(line1, line2)), entry.LyricLine1, entry.LyricLine2); 261 | _line1 = entry.LyricLine1; 262 | _line2 = entry.LyricLine2; 263 | } 264 | } 265 | 266 | public string[] GetProviders() { return null; } 267 | } 268 | } -------------------------------------------------------------------------------- /DesktopLyrics.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | 9.0.30729 8 | 2.0 9 | {F5D46BA1-6F21-40EF-9695-46105CCACD08} 10 | Library 11 | Properties 12 | MusicBeePlugin 13 | mb_DesktopLyrics 14 | v4.7.2 15 | 512 16 | 17 | 18 | 3.5 19 | 20 | false 21 | publish\ 22 | true 23 | Disk 24 | false 25 | Foreground 26 | 7 27 | Days 28 | false 29 | false 30 | true 31 | 0 32 | 1.0.0.%2a 33 | false 34 | true 35 | 36 | 37 | 38 | 39 | 40 | true 41 | full 42 | false 43 | bin\Debug\ 44 | DEBUG;TRACE 45 | prompt 46 | 4 47 | false 48 | false 49 | 50 | 51 | pdbonly 52 | true 53 | bin\Release\ 54 | TRACE 55 | prompt 56 | 4 57 | false 58 | 59 | 60 | true 61 | bin\x86\Debug\ 62 | DEBUG;TRACE 63 | full 64 | x86 65 | prompt 66 | true 67 | true 68 | false 69 | 70 | 71 | bin\x86\Release\ 72 | TRACE 73 | true 74 | pdbonly 75 | x86 76 | prompt 77 | false 78 | false 79 | false 80 | 81 | 82 | 83 | 84 | 85 | 86 | packages\Costura.Fody.3.2.2\lib\net40\Costura.dll 87 | 88 | 89 | packages\Cyotek.Windows.Forms.ColorPicker.1.7.2\lib\net35\Cyotek.Windows.Forms.ColorPicker.dll 90 | 91 | 92 | packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | Form 104 | 105 | 106 | FrmLyrics.cs 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | Form 118 | 119 | 120 | FrmSettings.cs 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | False 131 | Microsoft .NET Framework 4 %28x86 and x64%29 132 | true 133 | 134 | 135 | False 136 | .NET Framework 3.5 SP1 Client Profile 137 | false 138 | 139 | 140 | False 141 | .NET Framework 3.5 SP1 142 | false 143 | 144 | 145 | False 146 | Windows Installer 3.1 147 | true 148 | 149 | 150 | 151 | 152 | FrmLyrics.cs 153 | 154 | 155 | FrmSettings.cs 156 | Designer 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | $(TargetPath) 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /DesktopLyrics.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2027 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesktopLyrics", "DesktopLyrics.csproj", "{F5D46BA1-6F21-40EF-9695-46105CCACD08}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x86 = Debug|x86 12 | Release|Any CPU = Release|Any CPU 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {F5D46BA1-6F21-40EF-9695-46105CCACD08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {F5D46BA1-6F21-40EF-9695-46105CCACD08}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {F5D46BA1-6F21-40EF-9695-46105CCACD08}.Debug|x86.ActiveCfg = Debug|x86 19 | {F5D46BA1-6F21-40EF-9695-46105CCACD08}.Debug|x86.Build.0 = Debug|x86 20 | {F5D46BA1-6F21-40EF-9695-46105CCACD08}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {F5D46BA1-6F21-40EF-9695-46105CCACD08}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {F5D46BA1-6F21-40EF-9695-46105CCACD08}.Release|x86.ActiveCfg = Release|x86 23 | {F5D46BA1-6F21-40EF-9695-46105CCACD08}.Release|x86.Build.0 = Release|x86 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {EB615287-39A7-4AB9-B546-DBC461DD1093} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /FodyWeavers.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /FodyWeavers.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks 13 | 14 | 15 | 16 | 17 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. 18 | 19 | 20 | 21 | 22 | A list of unmanaged 32 bit assembly names to include, delimited with line breaks. 23 | 24 | 25 | 26 | 27 | A list of unmanaged 64 bit assembly names to include, delimited with line breaks. 28 | 29 | 30 | 31 | 32 | The order of preloaded assemblies, delimited with line breaks. 33 | 34 | 35 | 36 | 37 | 38 | This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. 39 | 40 | 41 | 42 | 43 | Controls if .pdbs for reference assemblies are also embedded. 44 | 45 | 46 | 47 | 48 | Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. 49 | 50 | 51 | 52 | 53 | As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. 54 | 55 | 56 | 57 | 58 | Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. 59 | 60 | 61 | 62 | 63 | Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. 64 | 65 | 66 | 67 | 68 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | 69 | 70 | 71 | 72 | 73 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. 74 | 75 | 76 | 77 | 78 | A list of unmanaged 32 bit assembly names to include, delimited with |. 79 | 80 | 81 | 82 | 83 | A list of unmanaged 64 bit assembly names to include, delimited with |. 84 | 85 | 86 | 87 | 88 | The order of preloaded assemblies, delimited with |. 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. 97 | 98 | 99 | 100 | 101 | A comma-separated list of error codes that can be safely ignored in assembly verification. 102 | 103 | 104 | 105 | 106 | 'false' to turn off automatic generation of the XML Schema file. 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /FontConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Drawing; 4 | using System.Text.RegularExpressions; 5 | using Newtonsoft.Json; 6 | 7 | namespace MusicBeePlugin 8 | { 9 | internal class FontConverter : JsonConverter 10 | { 11 | private static TypeConverter Converter { get; } = TypeDescriptor.GetConverter(typeof(Font)); 12 | 13 | public override void WriteJson(JsonWriter writer, Font value, JsonSerializer serializer) 14 | { 15 | writer.WriteValue(Converter.ConvertToInvariantString(value)); 16 | } 17 | 18 | public override Font ReadJson(JsonReader reader, Type objectType, Font existingValue, bool hasExistingValue, JsonSerializer serializer) 19 | { 20 | var str = serializer.Deserialize(reader); 21 | try 22 | { 23 | return (Font) Converter.ConvertFromInvariantString(str); 24 | } 25 | catch (Exception) 26 | { 27 | // Fallback to legacy 28 | return ConvertFromLegacyString(str); 29 | } 30 | } 31 | 32 | private static Font ConvertFromLegacyString(string str) 33 | { 34 | var m = Regex.Match( 35 | str, 36 | "^(?[\\w ]+),(?(\\d+(\\.\\d+)?))(,(?