﻿function dotXaml (name, x, y)
{
    return '<Ellipse xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" RenderTransformOrigin="0.5,0.5" Fill="#FF00FF00" Stroke="#FF00FF00" x:Name="'+name+'" Width="11" Height="11" Canvas.Left="'+x+'" Canvas.Top="'+y+'" />';
}

function flagXaml (name, x, y)
{
   return '<Path  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" RenderTransformOrigin="1,1" '
        +' Canvas.Left="'+x+'" Canvas.Top="'+y+'" Fill="#88FF0000" Stretch="Fill" Stroke="#88FF0000" '
		+' x:Name="'+name+'" Width="20.64" Height="20" '
		+' Data="M272,331 L258,307 C258,307 251,320 251,320 260.31452,322.61644 259.6371,313.90411 259.6371,313.90411 267.08871,324.9178 270.64516,331.65753 270.64516,331.65753 272.67742,330.34246 272,331 272,331 z" '
		+' />';
}

function flagNameXaml (name, x, y)
{
      return '<Canvas xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="'+(x-21)+'" Canvas.Top="'+(y-21)+'" x:Name="'+name+'" Opacity="1.0">'
        +' <Path  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" RenderTransformOrigin="1,1" '
        +' Fill="#880000FF" Stretch="Fill" Stroke="#880000FF" '
		+' Width="20.64" Height="20" '
		+' Data="M272,331 L258,307 C258,307 251,320 251,320 260.31452,322.61644 259.6371,313.90411 259.6371,313.90411 267.08871,324.9178 270.64516,331.65753 270.64516,331.65753 272.67742,330.34246 272,331 272,331 z" '
		+' />'
		+' <TextBlock Canvas.Left="20" Width="16" Height="20" Text="'+name+'" FontSize="11" Foreground="#FF0000FF" />'
		+' </Canvas>';
}

function flagImageXaml (name, x, y, url)
{
      return '<Canvas xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Canvas.Left="'+(x-21)+'" Canvas.Top="'+(y-21)+'" x:Name="'+name+'" Opacity="1.0">'
        /*+' <Image Canvas.Left="0" Canvas.Top="0" Width="50" Height="50" Source="http://www.solarviews.com/thumb/mars/marsatmo.jpg" />'
        */+' <Path  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" RenderTransformOrigin="1,1" '
        +' Fill="#880000FF" Stretch="Fill" Stroke="#880000FF" '
		+' Width="20.64" Height="20" '
		+' Data="M272,331 L258,307 C258,307 251,320 251,320 260.31452,322.61644 259.6371,313.90411 259.6371,313.90411 267.08871,324.9178 270.64516,331.65753 270.64516,331.65753 272.67742,330.34246 272,331 272,331 z" '
		+' />'
		+' <TextBlock Canvas.Left="20" Width="16" Height="20" Text="'+name+'" FontSize="11" Foreground="#FF0000FF" />'
		+' </Canvas>';
}

function drawFlag (name, x, y)
{
	var plugin = document.getElementById("SilverlightControl");
    var canvas = plugin.content.findName("canvasMarkers");
    var xaml   = flagNameXaml  (name, x, y); // dotXaml flagXaml
    var xamlC  = plugin.content.createFromXaml(xaml);
    canvas.children.add(xamlC);
}