sfSystemDialogs.cs
上传用户:lctyggxszx
上传日期:2022-06-30
资源大小:280k
文件大小:2k
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using AxShockwaveFlashObjects;
- using Mueller.Wddx;
- namespace SharpFlash
- {
- /// <summary>
- /// Summary description for sfSystemDialogs
- /// </summary>
- public class sfSystemDialogs
- {
- private static WddxSerializer wddxSerializer = new WddxSerializer();
- private static WddxDeserializer wddDeserializer = new WddxDeserializer();
-
- public sfSystemDialogs() {
- }
- public static void Command(Form form, AxShockwaveFlash flashApp, string list, String method) {
- switch(method) {
- case "BrowseForFile_Open":
- sfSystemDialogs.BrowseForFile_Open(form, flashApp, list);
- break;
- }
- }
- public static void BrowseForFile_Open(Form form, AxShockwaveFlash flashApp, string list) {
- System.Collections.Hashtable args = (System.Collections.Hashtable)wddDeserializer.Deserialize(list);
- OpenFileDialog fdlg = new OpenFileDialog();
- fdlg.FileName = args["fileName"].ToString();
- fdlg.Title = args["caption"].ToString();
- fdlg.InitialDirectory = args["initialPath"].ToString();
- fdlg.Filter = args["typeFilter"].ToString(); // "All files (*.*)|*.*"
- fdlg.CheckFileExists = false;
- fdlg.FilterIndex = 1;
- fdlg.RestoreDirectory = true;
-
- bool ok = false;
- if(fdlg.ShowDialog() == DialogResult.OK)
- {
- ok = true;
- }
-
- flashApp.SetVariable("$SFData", "<sf><callback><id>" + args["callback_id"] + "</id>"
- + "<args>"
- + "<arg>" + wddxSerializer.Serialize(ok).ToString() + "</arg>"
- + "<arg>" + wddxSerializer.Serialize(fdlg.FileName).ToString() + "</arg>"
- + "</args></callback></sf>");
- }
- }
- }