2007年10月17日

Developing Silverlight on Mac Cont. 3

Let's prepare other files.
The other files are Default.htm and createSilverlight.js .
These files are normal html and Javascript file.
Nothing special. But all words in these files are needed to run Silverlight.
If you don't understand Tags or Javascript, don't worry. You will understand soon.
Now, do not think too much. Just think as some Magic words here.

Default.htm
Please copy and paste from the file in SDK or from below.

<!DOCTYPE html PUBLIC  "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>A Sample HTML page</title>
<script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript" src="createSilverlight.js"></script>
</head>
<body>
<!-- Where the Silverlight plug-in will go-->
<div id="mySilverlightPluginHost">
</div>
<script type="text/javascript">
// Retrieve the div element you created in the previous step.
var parentElement =
document.getElementById("mySilverlightPluginHost");
// This function creates the Silverlight plug-in.
createMySilverlightPlugin();
</script>
</body>
</html>
------------------------
You can modify Title and JavaScript name if you don't like.



createSilverlight.js
Please copy from below.

// JScript source code
//contains calls to silverlight.js, examples are below
//setting the alpha-channel in the 'background' parameter drastically affects the cost of rendering
function createSilverlight()
{
//example calls, please replace with calls that match your site's requirements
//Silverlight.createObject("xaml/piano.xaml", pe, "SlControl1",
//{width:'1024', height:'530', inplaceInstallPrompt:false, background:'white', isWindowless:'false', framerate:'24', enableFramerateCounter:'false', version:'1.0'},
//{onError:null, onLoad:null, onResize:onResize},
//null);
//Silverlight.createObjectEx({source: 'xaml/piano.xaml', parentElement:pe, id:'SlControl1', properties:{width:'1024', height:'530', background:'white', isWindowless:'false', framerate:'24', enableFramerateCounter:'false', version:'1.0'}, events:{onError:null, onLoad:null, onResize:null}, context:null});

}

function createMySilverlightPlugin()
{
Silverlight.createObject(
"mySilverlight.xaml", // Source property value.
parentElement, // DOM reference to hosting DIV tag.
"mySilverlightPlugin", // Unique plug-in ID value.
{ // Per-instance properties.
width:'500', // Width of rectangular region of
// plug-in area in pixels.
height:'500', // Height of rectangular region of
// plug-in area in pixels.
inplaceInstallPrompt:false, // Determines whether to display
// in-place install prompt if
// invalid version detected.
background:'#D6D6D6', // Background color of plug-in.
isWindowless:'false', // Determines whether to display plug-in
// in Windowless mode.
framerate:'24', // MaxFrameRate property value.
version:'1.0' // Silverlight version to use.
},
{
onError:null, // OnError property value --
// event handler function name.
onLoad:null // OnLoad property value --
// event handler function name.
},
null); // Context value -- event handler function name.
}
------------------------------
In this file, function createMySilverlightPlugin() is important part.
Please see below part;
Silverlight.createObject(
"mySilverlight.xaml",

I named mySilverlight.xaml, so I put this name. But if you named it diffrent, please replace it to your xaml file name.

After you have done from here, please save and open Default.htm by your browser or from Eclipse.
I hope you can see a circle on it.
For Next, let's add Event on Xaml.


***********

All codes above are created by Microsoft.

0 件のコメント: