Visual Studio 2019 Community 16.8.5
C#
SDR# Plugin SDK for .NET 5 https://airspy.com/download/
Latest SDR# versions need .NET 5 desktop runtime and plugin development is also changed from prev versions due change to .NET 5. For developing plugins for SDR# .NET 5 install the latest version of VS 2019 and enable in tools -> options
Show all .NET Core templates in the New project dialog
Use the preview Windows Forms designer for .NET Core apps
Create a new project using template Class Library - a project for creating a class library that targets .NET Standard or .NET Core
Add these lines to VS project file especially if you are going to use WinForm controls in plugin: <UseWindowsForms>true</UseWindowsForms>
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<OutputType>Library</OutputType>
<Platforms>AnyCPU</Platforms>
<UseWindowsForms>true</UseWindowsForms>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<AssemblyName>SDRSharp.Plugin.Rdsi</AssemblyName>
</PropertyGroup>
change text in references property group (SDRSharp.Common ...) to:
<ItemGroup>
<Reference Include="SDRSharp.Common">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\SDRSharp.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SDRSharp.PanView">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\SDRSharp.PanView.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="SDRSharp.Radio">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\SDRSharp.Radio.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
... and reload the project after editing VS project file.
... otherwise you get lots of errors when building the solution.
Add references to SDRSharp.Common and .Radio and .Panview. Create a directory e.g. vendor and copy files from SDR# Plugin SDK for .NET 5 lib folder.
// implement at least ISharpPlugin, ICanLazyLoadGui, ISupportStatus
// See the examples in SDR# .NET 5 plugin SDK
using SDRSharp.Common;
using SDRSharp.Radio;
using System.Windows.Forms;
namespace SDRSharp.Plugin.Rdsi
{
public class RdsiPlugin : ISharpPlugin, ICanLazyLoadGui, ISupportStatus
{
private const string _displayName = "RDS";
private ISharpControl _controlInterface;
private RdsiPluginPanel _configGui;
public string DisplayName
{
get { return _displayName; }
}
public UserControl Gui
{
get
{
LoadGui();
return _configGui;
}
}
public void Close()
{
}
public bool IsActive => true;
public void Initialize(ISharpControl control)
{
_controlInterface = control;
_configGui = new RdsiPluginPanel(_controlInterface);
control.RegisterStreamHook((object)new RdsHwnd(_configGui), ProcessorType.RDSBitStream);
}
public void LoadGui()
{
if (_configGui == null)
{
_configGui = new RdsiPluginPanel(_controlInterface);
}
}
}
}
For user control (GUI) I copied files (User control: RdsiPluginPanel cs, resx and designer files) from RDS logger plugin I had coded for older versions of SDR# (no Telerik, no .NET 5 https://github.com/OH1GIU-P/SDRSharp.Rdsiplugin). When building VS showed error message: dispose is not implemented, fix: RdsiPluginPanel.cs => view in designer.
https://i.ibb.co/g3qCc8N/vs-plugin-dev.png
I also added IMustLoadGui
public class RdsiPlugin : ISharpPlugin, ICanLazyLoadGui, IMustLoadGui, ISupportStatus
and method public bool LoadNeeded
public void Close()
{
}
public bool IsActive => true;
public bool LoadNeeded => true;
Added magic line into Plugins.xml
<?xml version="1.0" encoding="utf-8" ?>
<sharpPlugins>
<add key="RDS" value="SDRSharp.Plugin.Rdsi.RdsiPlugin,SDRSharp.Plugin.Rdsi" />
</sharpPlugins>
User control UI imported from my old SDR# plugin needs some fixing...
Kommentit
Tämän blogin kommentit tarkistetaan ennen julkaisua.