📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private ExternalInterfaceSerializer serializer = new ExternalInterfaceSerializer();
private AxShockwaveFlashObjects.AxShockwaveFlash axShockwaveFlash1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.axShockwaveFlash1 = new AxShockwaveFlashObjects.AxShockwaveFlash();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.axShockwaveFlash1)).BeginInit();
this.SuspendLayout();
//
// axShockwaveFlash1
//
this.axShockwaveFlash1.Enabled = true;
this.axShockwaveFlash1.Location = new System.Drawing.Point(16, 16);
this.axShockwaveFlash1.Name = "axShockwaveFlash1";
this.axShockwaveFlash1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axShockwaveFlash1.OcxState")));
this.axShockwaveFlash1.Size = new System.Drawing.Size(408, 120);
this.axShockwaveFlash1.TabIndex = 0;
this.axShockwaveFlash1.FlashCall += new AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEventHandler(this.axShockwaveFlash1_FlashCall);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(16, 152);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(408, 112);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 272);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(408, 23);
this.button1.TabIndex = 2;
this.button1.Text = "Send to Flash";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(440, 302);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.axShockwaveFlash1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.axShockwaveFlash1)).EndInit();
this.ResumeLayout(false);
}
private object CSharpToFlash(string command,string values)
{
ArrayList args=new ArrayList();
args.Add(command);
args.Add(values);
string request = serializer.EncodeInvoke("CSharpToFlash", args);
object returnObj;
try
{
string resultXML = this.axShockwaveFlash1.CallFunction(request);
returnObj = serializer.DecodeResult(resultXML);
}
catch(System.Exception e)
{
returnObj=e.Message;
}
return returnObj;
}
private void axShockwaveFlash1_FlashCall(object sender,AxShockwaveFlashObjects._IShockwaveFlashEvents_FlashCallEvent evt)
{
serializer.DecodeInvoke(evt.request);
if(serializer.functionName=="FlashToCSharp")
{
string returnStr="0";
string command=serializer.arguments[0].ToString();
string values="";
if(serializer.arguments.Count>1)
{
values=serializer.arguments[1].ToString();
}
this.textBox1.Text=command+":"+values;
returnStr=command+":"+values+" 发送成功!";
returnStr=serializer.EncodeResult(returnStr);
this.axShockwaveFlash1.SetReturnValue(returnStr);
}
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, EventArgs e)
{
CSharpToFlash(this.textBox1.Text,"");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -