<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Silverlight OpenSocial" width="640" height="200" author="Michael S. Scherotter" author_email="mischero@microsoft.com" scaling="true" description="A demonstration of using Microsoft Silverlight in an OpenSocial application." author_affiliation="Microsoft Corporation" author_location="Fairfax, California" title_url="http://blogs.msdn.com/synergist">
<Require feature="opensocial-0.5" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript" src="http://hosting.gmodules.com/ig/gadgets/file/113009390747258006757/Silverlight.js">
</script>
<script type="text/xaml" id="XAML">
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="640" Height="200"
x:Name="Page" RenderTransformOrigin="0.5,0.5"
>
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1.0" ScaleY="1" x:Name="Scale"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0" x:Name="Translation"/>
</TransformGroup>
</Canvas.RenderTransform>
<Canvas.Triggers>
<EventTrigger RoutedEvent="Canvas.Loaded">
<BeginStoryboard>
<Storyboard x:Name="Startup" RepeatBehavior="Forever" AutoReverse="True">
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[2].(BezierSegment.Point2)">
<SplinePointKeyFrame KeyTime="00:00:00" Value="484.749503478214,48.4614211008539" KeySpline="0.766,0,0.265,0.991"/>
<SplinePointKeyFrame KeyTime="00:00:01" Value="472.99841325265,33.7398233257606" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="482.133751598516,55.9324453754571" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[2].(BezierSegment.Point3)">
<SplinePointKeyFrame KeyTime="00:00:01" Value="513.106656180137,46.7546299392857" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="499.186383177463,42.3922334944287" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[3].(BezierSegment.Point1)">
<SplinePointKeyFrame KeyTime="00:00:00" Value="540.59991701205,19.6227330505653" KeySpline="0.766,0,0.265,0.991"/>
<SplinePointKeyFrame KeyTime="00:00:01" Value="564.908523302214,63.5639248274273" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="525.339507767719,21.6260047359191" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(BezierSegment.Point2)">
<SplinePointKeyFrame KeyTime="00:00:00" Value="256.689637283039,7.23634631616016" KeySpline="0.766,0,0.265,0.991"/>
<SplinePointKeyFrame KeyTime="00:00:01" Value="248.899873242055,57.1432452148108" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="233.195785457065,-22.4606421224457" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(BezierSegment.Point3)">
<SplinePointKeyFrame KeyTime="00:00:01" Value="295.076580992168,24.6446375615999" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="298.817962124832,21.7698995286644" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[2].(BezierSegment.Point1)">
<SplinePointKeyFrame KeyTime="00:00:00" Value="350.699783207225,60.8478078352592" KeySpline="0.766,0,0.265,0.991"/>
<SplinePointKeyFrame KeyTime="00:00:01" Value="341.253288742281,-7.85397009161106" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="364.440138792599,66.0004411797744" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(BezierSegment.Point2)">
<SplinePointKeyFrame KeyTime="00:00:00" Value="111.373548722153,61.3389964335705" KeySpline="0.766,0,0.265,0.991"/>
<SplinePointKeyFrame KeyTime="00:00:01" Value="119.007495207789,17.6773995669566" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="143.912099951412,61.4751946548156" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(BezierSegment.Point3)">
<SplinePointKeyFrame KeyTime="00:00:01" Value="160.569841824079,45.703395381752" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="160.569841824079,45.703395381752" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(BezierSegment.Point1)">
<SplinePointKeyFrame KeyTime="00:00:00" Value="199.555871768111,6.74515771784889" KeySpline="0.766,0,0.265,0.991"/>
<SplinePointKeyFrame KeyTime="00:00:01" Value="202.132188440369,73.7293911965473" KeySpline="0.641,0,0.094,0.999"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="177.227583696746,29.9315961086885" KeySpline="0.5,0,0.188,0.983"/>
</PointAnimationUsingKeyFrames>
<PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Wave" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(BezierSegment.Point1)">
<SplinePointKeyFrame KeyTime="00:00:01" Value="2.27346024513245,34.0420770757097"/>
<SplinePointKeyFrame KeyTime="00:00:01.7000000" Value="-16.7514460054151,67.9340629439986"/>
</PointAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Canvas.Triggers>
<Canvas.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#FF9A0000" Offset="1"/>
</LinearGradientBrush>
</Canvas.Background>
<Path x:Name="Wave" Width="649.767" Height="103.169" Stretch="None" Stroke="#FF000000" Canvas.Top="96.952" Canvas.Left="-9.767">
<Path.Data>
<PathGeometry>
<PathFigure IsClosed="True" StartPoint="2.27346024513245,34.0420770757097">
<BezierSegment Point1="2.27346024513245,34.0420770757097" Point2="155.464710245132,34.0420770757097" Point3="155.464710245132,34.0420770757097"/>
<BezierSegment Point1="2.27346024513245,34.0420770757097" Point2="303.694710245132,34.0420770757097" Point3="303.694710245132,34.0420770757097"/>
<BezierSegment Point1="2.27346024513245,34.0420770757097" Point2="512.674710245132,34.0420770757097" Point3="512.674710245132,34.0420770757097"/>
<BezierSegment Point1="2.27346024513245,34.0420770757097" Point2="649.260960245132,34.0420770757097" Point3="649.260960245132,34.0420770757097"/>
<LineSegment Point="649.260960245132,102.669338474509"/>
<LineSegment Point="2.27346024513245,102.669338474509"/>
</PathFigure>
</PathGeometry>
</Path.Data>
<Path.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF406BF6" Offset="1"/>
<GradientStop Color="#FF04123C" Offset="0.983"/>
<GradientStop Color="#FFFF7100" Offset="0.353"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
<Ellipse Width="1000" Height="1000" Stroke="#FF000000" Canvas.Left="-544.2" Canvas.Top="32">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="#FF406BF6" Offset="1"/>
<GradientStop Color="#FF04123C" Offset="0.983"/>
<GradientStop Color="#FF003CFF" Offset="0.353"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<TextBlock Width="164.2" Height="17.6" Canvas.Left="459.8" Canvas.Top="144.517" Text="Silverlight in OpenSocial" TextWrapping="Wrap" FontFamily="Trebuchet MS" Foreground="#FFFFFFFF"/>
<TextBlock Width="222.4" Height="17.6" Canvas.Left="401.6" Canvas.Top="166.117" Text="http://blogs.msdn.com/synergist" TextWrapping="Wrap" FontFamily="Trebuchet MS" Foreground="#FFFFFFFF"/>
<TextBlock Width="303.2" Height="59.2" Text="Friends" TextWrapping="Wrap" x:Name="Title" FontFamily="Trebuchet MS" FontSize="22" Canvas.Top="8" Canvas.Left="8"/>
<Image Width="75" Height="75" x:Name="Image" Stretch="Uniform" Canvas.Top="117" Canvas.Left="8"/>
<Canvas Width="306" Height="121.328" Canvas.Left="326" Canvas.Top="8" x:Name="Friends"/>
</Canvas></script>
<script type="text/xaml" id="Friend">
<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="20">
<TextBlock Canvas.Left="0" FontSize="12" FontFamily="Trebuchet MS" x:Name="Name"/>
</Canvas> 
</script>
<script type="text/javascript">
var m_root = null;
_IG_RegisterOnloadHandler(createSilverlight);

function request() 
{
var text = m_root.findName("Title");
text.Text = "Requesting friends...";
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
req.add(req.newFetchPeopleRequest ('VIEWER_FRIENDS'), 'viewerFriends');
req.send(onLoadFriends); 
}
function onLoadFriends(dataResponse) 
{
var text = m_root.findName("Title");
var image = m_root.findName("Image");

text.Text = "Friends Loaded.";
var viewer = dataResponse.get("viewer").getData();

var thumb = viewer.getField(opensocial.Person.Field.THUMBNAIL_URL);
text.Text = "Friends of " + viewer.getDisplayName(); 
image.Source = thumb;
var viewerFriends = dataResponse.get("viewerFriends").getData();

var parent = m_root.findName("Friends");
var top = 0;
var host = m_root.getHost();

var xaml = document.getElementById("Friend").innerText;

if (xaml == null)
{
xaml = document.getElementById("Friend").textContent;
}

viewerFriends.each(function(person) 
{
var friend = host.content.createFromXaml(xaml, true);
friend["Canvas.Top"] = top;
top+= friend.Height + 5;
var name = friend.findName("Name");
name.Text = person.getDisplayName();
parent.children.Add(friend);
});
}

function createSilverlight()
{ 
var pe = document.getElementById("SilverlightHost");

Silverlight.createObject("#XAML", pe, "SilverlightControl",
{width:'100%', height:'100%', inplaceInstallPrompt:true, background:'White', isWindowless: 'false', framerate:'24', enableFramerateCounter:false, version:'1.0'},
{onLoad:OnLoad},
null);
}

function OnLoad(sender, context, source)
{
var host = source.getHost();

host.content.onResize = OnResize;
m_root = source; 

request();

}

function OnResize(sender, eventArgs)
{
ResizeApplication();
}

function ResizeApplication()
{
var Translation = m_root.findName("Translation");
var Scale = m_root.findName("Scale");
var host = m_root.getHost();
var scaleX = host.content.ActualWidth / m_root.Width;
var scaleY = host.content.ActualHeight / m_root.Height;
var minScale = Math.min(scaleX, scaleY);
Scale.ScaleX = minScale;
Scale.ScaleY = minScale;
Translation.X = m_root.Width * (scaleX - Scale.ScaleX) / 2;
Translation.Y = m_root.Height * (scaleY - Scale.ScaleY) / 2;
}

</script>
<div id="SilverlightHost">
</div>
]]>
</Content>
</Module>
