浏览 2646 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-11-21
请看下面介绍: 程序代码: 下面代码负责实现和旺旺IM通讯的接口,这里只响应了onClick事件。 using System.Linq; using System; using System.Collections.Generic; using System.Threading; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Text; using wwsdkcomLib; using System.Xml; namespace JSHelper { public class Global { public static int lPluginCookie; public static int lCookie; public static object pSlot; public static string appid = "18265"; } [ComVisible(true), Guid("B221A17A-D3E7-44df-AD67-D45CFA4B5229"), ClassInterface(ClassInterfaceType.None)] public class Class1 : ISDKPlugin2 { public void OnConnect(object pApplication, int lPluginCookie) { // OnConnect 不建议使用末态对话框 //ISDKPluginQueryResult pqr = (pApplication as ISDKApplication3).GetSubScriptionInfo(lPluginCookie) as ISDKPluginQueryResult; //Global.appid = pqr.appID; } public void OnDisconnect(object pApplication, int lPluginCookie) { // OnDisConnect 不建议使用末态对话框 // MessageBox.Show("我被卸载了", "csharp helloworld"); } public void OnNotify(SDKMessageID MsgID, object pParam) { if (MsgID == SDKMessageID.NOTIFY_OFFLINE) { } else if (MsgID == SDKMessageID.NOTIFY_USERLOGIN) { } } public void OnUninstall() { } public void Require() { } } [ComVisible(true), Guid("950BFC6C-502A-4239-A36E-90893BA3B03E"), ClassInterface(ClassInterfaceType.None)] public class Class2 : ISDKPluginItem { Form1 f1; public void OnMenuClick(int lCmdID) { } // 插件作为按钮出现时候得到点击后被调用 // 本例中此方法将在点击发生后得到调用 public void OnClick() { try { this.f1.Show(); } catch(Exception ex) { this.f1 = new Form1(); this.f1.Show(); } } // 插件接入到插槽后得到通知 public void OnCreate(object pSlot, int hParentWnd, int lCookie) { } // 插件在附属插槽被销毁时候得到通知 public void OnDestroy() { // 使用模态对话框可能导致异常 // MessageBox.Show("聊天对话框输入工具条插件被销毁", "csharp allinone plugin"); } // 和插件项本身相关的消息通知 public void OnNotify(SDKItemNotifyID MsgIDD, object pParam) { } // 当插件以窗口形式出现情况下,在父窗口发生变化情况下得到通知 public void OnSize(int cx, int cy) { } } } 下面代码是JSHelper窗体主程序,没什么意思。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace JSHelper { public partial class Form1 : Form { String path; Form2 f2; Form2 f3; Form2 f4; Form2 f5; Form2 f6; public Form1() { InitializeComponent(); this.path = Application.StartupPath; this.webBrowser1.Url = new System.Uri(this.path + "\\plugins\\" + Global.appid + "\\src\\debugger.html", false); } private void ExamplesToolStripMenuItem_Click(object sender, EventArgs e) { try { System.Diagnostics.Process.Start("explorer", this.path + "\\plugins\\" + Global.appid + "\\src\\example\\");//+this.path } catch(Exception ex) { MessageBox.Show("请打开插件中的example目录.\n\n该目录的路径可能如下:\n" + this.path + "\\plugins\\" + Global.appid + "\\src\\example\\"); } } private void HideToolStripMenuItem_Click(object sender, EventArgs e) { this.Hide(); } private void ManualToolStripMenuItem_Click(object sender, EventArgs e) { try { this.f2.Show(); } catch { this.f2 = new Form2("使用说明", new System.Uri(this.path + "\\plugins\\" + Global.appid + "\\src\\readme\\KingfishersManual.html")); this.f2.Show(); } } private void AboutJSHelperToolStripMenuItem_Click(object sender, EventArgs e) { String[] info=new String[7]; info[0] = "Version:0.9.0"; info[1] = "Release Date:2008-11-17"; info[2] = "JSHelper是一款轻巧的Javascript调试工具,"; info[3] = "以旺旺插件形式发布在阿里软件平台,"; info[4] = "依赖于jzshmyt所写Kingfishers工具包。"; info[5] = "方便使用是我的唯一目的。"; info[6] = "Author : CharlesCui"; try { this.f3.Show(); } catch { this.f3 = new Form2("关于--JSHelper", String.Join("<p/><p/>", info, 0, info.Length)); this.f3.Show(); } } private void JavascriptlogToolStripMenuItem_Click(object sender, EventArgs e) { String[] info = new String[5]; info[0] = "Kingfishers是一个用javascript语言编写的,能够代替alert,在浏览器中连续输出客户端javascript脚本运行日志的工具。"; info[1] = "主要用于客户端脚本的分析和查错。"; info[2] = "GoogleCode:http://code.google.com/p/dewind/"; info[3] = "Download:http://dewind.googlecode.com/files/Kingfishers-1.0.rar"; info[4] = "Author : jzshmyt"; try { this.f4.Show(); } catch { this.f4 = new Form2("关于--Kingfishers", String.Join("<p/><p/>", info, 0, info.Length)); this.f4.Show(); } } private void AboutAuthorToolStripMenuItem_Click(object sender, EventArgs e) { String[] info = new String[4]; info[0] = "作者博客:<a href='http://charlescui.iteye.com'>http://charlescui.iteye.com</a>"; info[1] = "作者邮箱:<a href='mailto:zheng.cuizh@gmail.com?cc=zheng.cuizh@alibaba-inc.com'>zheng.cuizh@gmail.com</a>"; info[2] = "作者寄语:欢迎广大爱好插件开发(阿里旺旺\\Android)、系统性能调优的朋友们骚扰我!"; info[3] = "作者MSN:cuizheng.hz@hotmail.com"; try { this.f5.Show(); } catch { this.f5 = new Form2("关于--作者", String.Join("<p/><p/>", info, 0, info.Length)); this.f5.Show(); } } private void ParamsToolStripMenuItem_Click(object sender, EventArgs e) { try { this.f6.Show(); } catch { this.f6 = new Form2("参数说明", new System.Uri(this.path + "\\plugins\\" + Global.appid + "\\src\\readme\\KingfishersManual.txt")); this.f6.Show(); } } } } 下面代码是JSHelper实现页面的html: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <html> <head> <script type="text/javascript" src="logger.js" suspended=false simplemode=true skin = true cookie=false></script> <script> string_to_code=function(id){ content=document.getElementById("Content").value; return content.split('\n').join(';\n'); } </script> </head> <body> <table> <tr><td> <textarea rows="9" cols="40" id="Content"> //(JSCode) </textarea> </tr></td><tr><td> <input type=button value="Run" onclick='eval(string_to_code("Content"))' id=button1 name=button1/> <input type=button value="Clear" onclick='(document.getElementById("Content").value="")' id=button2 name=button2/> <input type=button value="Reset" onclick='(location.reload())' id=button3 name=button3/> <p/> </tr></td> </body> </html> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |