Login
Воспоминание Microsoft Silverlight 08.10.2024
424 просмотров
Перейти к просмотру всей ветки
uscheswoi_82 коренной житель
in Antwort uscheswoi_82 08.10.24 10:01, Zuletzt geändert 08.10.24 10:50 (uscheswoi_82)
Давайте из болтавни в практику, т.е. поиграемся с Microsoft Silverlight:
1. Запустим Microsoft Expression Blend 2
2. Нажмём на New Project...
3. Выберим Silverlight 1 Site:
Вот наш пустой экран:
4. Дальше сделаем так:
Вот код Default.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- saved from url=(0014)about:internet --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>SilverlightSite</title> <script type="text/javascript" src="Silverlight.js"></script> <script type="text/javascript" src="Page.xaml.js"></script> <style type="text/css"> #silverlightControlHost { height: 480px; width: 640px; } #errorLocation { font-size: small; color: Gray; } </style> <script type="text/javascript"> function createSilverlight() { var scene = new SilverlightSite.Page(); Silverlight.createObjectEx({ source: "Page.xaml", parentElement: document.getElementById("silverlightControlHost"), id: "SilverlightControl", properties: { width: "100%", height: "100%", version: "1.0" }, events: { onLoad: Silverlight.createDelegate(scene, scene.handleLoad), onError: function(sender, args) { var errorDiv = document.getElementById("errorLocation"); if (errorDiv != null) { var errorText = args.errorType + "- " + args.errorMessage; if (args.ErrorType == "ParserError") { errorText += " File: " + args.xamlFile; errorText += ", line " + args.lineNumber; errorText += " character " + args.charPosition; } else if (args.ErrorType == "RuntimeError") { errorText += " line " + args.lineNumber; errorText += " character " + args.charPosition; } errorDiv.innerHTML = errorText; } } } }); } if (!window.Silverlight) Silverlight = {}; Silverlight.createDelegate = function(instance, method) { return function() { return method.apply(instance, arguments); } } </script> </head> <body> <div id="silverlightControlHost"> <script type="text/javascript"> createSilverlight(); </script> </div> <!-- Runtime errors from Silverlight will be displayed here. This will contain debugging information and should be removed or hidden when debugging is completed --> <div id='errorLocation'></div> </body> </html>
Вот код Page.xaml:
<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="640" Height="480" Background="White" x:Name="Page"> <TextBlock Canvas.Left="139" Canvas.Top="58" Width="175" Height="31" TextWrapping="Wrap" Foreground="#FFFF0000" Cursor="Hand" FontWeight="Bold" FontFamily="Lucida Sans Unicode" FontSize="20"><Run Text="Заголовок сайта"/> </TextBlock> </Canvas>
Вот код Page.xaml.js:
if (!window.SilverlightSite) SilverlightSite = {}; SilverlightSite.Page = function(){} SilverlightSite.Page.prototype = { handleLoad: function(control, userContext, rootElement) { this.control = control; // Sample event hookup: rootElement.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown)); }, // Sample event handler handleMouseDown: function(sender, eventArgs) { // The following line of code shows how to find an // element by name and call a method on it. // this.control.content.findName("Storyboard1").Begin(); }}
Код Silverlight.js сильно большой.
Если я кому-то отвечаю, это не значит что я ему симпатизирую, каждый остаётся при своём мнение
Tagebuch der schwerbehinderten Person