using AxShockwaveFlashObjects;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
//Flash通信参考了Copyright : xiongfenghui,谢谢他的分享!!
/*
Flash与C#通信主要是通过XML来通迅,并且有相对比较固定的格式,主要格式如下:
<invoke name="setValue" returntype="XML"> name表示调用函数的名称
<arguments> 参数列表
<string>Value1</string> 参数1
<string>Value2</string> 参数2
…… 参数n
</arguments>
</invoke>
*/
/*
* VS2015添加flash控件
*
* 1.在解决方案资源管理器,
* 在(References)引用上右键-->(Add References)添加引用-->左上角选择程序集--> “COM”中。
* 勾选“Shockwave Flash Object” ,确定即可。
* 2.工具箱上点鼠标右键,出现菜单,选择 "Choose Items...",
* 在出现的窗口选择"Com components"选项卡,
* 选择Shockwave Flash Object,打上勾,点"OK"按钮.
*
*/
namespace SerialFlashInteraction
{
public partial class Form1 : Form
{
public Form1() {
InitializeComponent();
//注册FlashCall事件
this.axShockwaveFlash1.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(axShockwaveFlash1_FlashCall);//注册事件
}
private SerialPort ComDevice;
string path = Application.StartupPath + "\\" + "系统文件" + ".txt";
string path1 = System.Windows.Forms.Application.StartupPath + "\\Flash\\" + "csharp" + ".swf";
//声明
string Mode; //模式
string PortName; //端口
string BaudRate; //波特率
string ParityBit; //校验位
string DataBits; //数据位
string StopBit; //停止位
private void Form1_Load(object sender, EventArgs e) {
DataRead();//读参数
SerialPortInit();//串口初始化
ComDevice.DataReceived += CD_DataReceived;//从串口读数据
ComDevice.Encoding = Encoding.GetEncoding("GB2312");//支持中文
CheckForIllegalCrossThreadCalls = false;//获取或设置一个值,该值指示是否捕获对错误线程的调用,这些调用在调试应用程序时访问控件的 Handle 属性。
if(this.Mode == "运行") {
axShockwaveFlash1.Movie = path1;
axShockwaveFlash1.Play();
//实现窗体内某控件的全屏显示
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
Rectangle ret = Screen.G