コード例 #1
0
ファイル: CSwfObject.cs プロジェクト: doctorgu/MadeIn9
        public static string GetScriptWrite(string Version, int Width, int Height,
                                            FlashAllowScriptAccess AllowScriptAccess, FlashWmode Wmode, FlashSalign Salign, FlashScale Scale,
                                            Color BgColor, string FlashVars, string Movie, string FlashId, string DivIdForContainer)
        {
            string DivId = string.IsNullOrEmpty(DivIdForContainer) ? "div" + FlashId : DivIdForContainer;

            Dictionary <string, string> nv = new Dictionary <string, string>();

            nv.Add("menu", "false");
            nv.Add("allowScriptAccess", AllowScriptAccess.ToString());
            nv.Add("wmode", Wmode.ToString());
            nv.Add("salign", Salign.ToString());
            nv.Add("scale", Scale.ToString());
            nv.Add("bgcolor", CColorConv.GetHexaByColor(BgColor));
            nv.Add("flashvars", FlashVars);
            string Params = CScript.GetScriptKeyValueByColon(nv, true);

            string s = "";

            if (string.IsNullOrEmpty(DivIdForContainer))
            {
                s += "<div id=\"" + DivId + "\">" +
                     "<a href=\"http://www.adobe.com/go/getflashplayer\">" +
                     "<img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" />" +
                     "</a>" +
                     "</div>\r\n";
            }

            List <string> aStmt = new List <string>();

            aStmt.Add("var flashvars = false;");
            aStmt.Add("var params = { " + Params + " };");
            aStmt.Add("var attributes = { id: \"" + FlashId + "\", name: \"" + FlashId + "\" };");
            aStmt.Add("swfobject.embedSWF(\"" + Movie + "\", \"" + DivId + "\", \"" + Width.ToString() + "\", \"" + Height.ToString() + "\", \"" + Version + "\", \"\", flashvars, params, attributes);");

            string s2 = CScript.GetScript(aStmt, true);

            return(s + s2);
        }
コード例 #2
0
ファイル: CSilverlight.cs プロジェクト: doctorgu/MadeIn9
        public static string GetScript(string Source, string Id,
                                       SInfoSilverlightProperties Properties, SInfoSilverlightEvents Events,
                                       Dictionary <string, string> InitParams)
        {
/*
 * <div id="silverlightControlHost">
 *      <script type="text/javascript">
 *      var source = "/ClientBin/RoundedBox.xap";
 *      var parentElement = silverlightControlHost;
 *      var id = "slPlugin";
 *      var properties = {
 *              width: "100", height: "100",
 *              background: "white", alt: alt,
 *              minRuntimeVersion: "2.0.30800.0"
 *      };
 *      var events = { onError: onSLError, onLoad: onSLLoad };
 *      var initParams = "param1=value1,param2=value2";
 *
 *      Silverlight.createObject(source, parentElement, id, properties, events, initParams, "");
 * </script>
 * </div>
 */
            string DivId = "div" + Id;

            List <string> aStmt = new List <string>();

            aStmt.Add("var source = \"" + Source + "\";");
            aStmt.Add("var parentElement = " + DivId + ";");
            aStmt.Add("var id = \"" + Id + "\";");

            aStmt.Add("var properties = {");
            Dictionary <string, string> dicProperties = new Dictionary <string, string>();

            if (Properties.width != 0)
            {
                dicProperties.Add("width", Properties.width.ToString());
            }
            if (Properties.height != 0)
            {
                dicProperties.Add("height", Properties.height.ToString());
            }
            if (!string.IsNullOrEmpty(Properties.background))
            {
                dicProperties.Add("background", Properties.background);
            }
            if (!string.IsNullOrEmpty(Properties.alt))
            {
                dicProperties.Add("alt", Properties.alt);
            }
            if (!string.IsNullOrEmpty(Properties.minRuntimeVersion))
            {
                dicProperties.Add("minRuntimeVersion", Properties.minRuntimeVersion);
            }
            aStmt.Add(CScript.GetScriptKeyValueByColon(dicProperties, true));
            aStmt.Add("};");

            aStmt.Add("var events = {");
            Dictionary <string, string> dicEvents = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(Events.onError))
            {
                dicEvents.Add("onError", Events.onError);
            }
            if (!string.IsNullOrEmpty(Events.onFullScreenChanged))
            {
                dicEvents.Add("onFullScreenChanged", Events.onFullScreenChanged);
            }
            if (!string.IsNullOrEmpty(Events.onLoaded))
            {
                dicEvents.Add("onLoaded", Events.onLoaded);
            }
            if (!string.IsNullOrEmpty(Events.onResized))
            {
                dicEvents.Add("onResized", Events.onResized);
            }
            if (!string.IsNullOrEmpty(Events.onSourceDownloadComplete))
            {
                dicEvents.Add("onSourceDownloadComplete", Events.onSourceDownloadComplete);
            }
            if (!string.IsNullOrEmpty(Events.onSourceDownloadProgressChanged))
            {
                dicEvents.Add("onSourceDownloadProgressChanged", Events.onSourceDownloadProgressChanged);
            }
            aStmt.Add(CScript.GetScriptKeyValueByColon(dicEvents, true));
            aStmt.Add("};");

            aStmt.Add("var initParams = \"" + GetInitParams(InitParams) + "\";");

            aStmt.Add("Silverlight.createObject(source, parentElement, id, properties, events, initParams, \"\");");
            string Script = CScript.GetScript(aStmt, true);
            string s      = "<div id=\"" + DivId + "\">" + Script + "</div>\r\n";

            return(s);
        }