1、打开Visual Studio2012或其他版本,新建C#项目:
重新设置项目名,项目路径和解决方案名。
2、环境设置,右击项目名,点击属性:
Build->Platform target:x86
3、拷贝SCL_API.cs到项目文件下:
4、拷贝MiniLED.dll/MiniUtil.dll文件到调试路径下:
5、给窗体添加按钮控件,添加如下代码
namespace DemoCL3000_CSharp01
{
public partial class Form1 : Form
{
MyFun mfun = new MyFun();
const short mDevId = 10;
const string IPAddr = "10.1.1.100";
const short UDPPort = 8081;
const short TimeOut = 2;
const short RetryTimes = 1;
const short LedNum = 0;
const int Baudrate = 38400;
const int LedWidth = 320;
const int LedHeight = 64;
const short MLeft = 0;
const short MTop = 0;
const short XPos = 0;
const short YPos = 0;
const short Opt = 130;
const short Color = 1;
const string str = "123";
string s1 = "Line1Hi你好,深圳";
string s2 = "Line2Hi你好,深圳";
string s3 = "Line3Hi你好,深圳";
string s4 = "Line4Hi你好,深圳";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MShowString();
}
public void MShowString() {
string line1 = mfun.ReadLine(LedWidth, LedHeight, s1, (int)TextAlignment.LEFT);
string line2 = mfun.ReadLine(LedWidth, LedHeight, s2, (int)TextAlignment.LEFT);
string line3 = mfun.ReadLine(LedWidth, LedHeight, s3, (int)TextAlignment.LEFT);
string line4 = mfun.ReadLine(LedWidth, LedHeight, s4, (int)TextAlignment.LEFT);
SCL_API.MC_NetInitial(mDevId, "", IPAddr, TimeOut, RetryTimes, UDPPort);
SCL_API.MC_ShowString(mDevId, MLeft, MTop, LedWidth, LedHeight, XPos, YPos, Color, line1 + line2 + line3 + line4, Opt);
SCL_API.MC_Close(mDevId);
}
}
}