~ubuntu-branches/ubuntu/trusty/moon/trusty

« back to all changes in this revision

Viewing changes to test/xaml/assorted/test-collections.html

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-14 12:01:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090214120108-06539vb25vhbd8bn
Tags: upstream-1.0
Import upstream version 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 
2
<head>
 
3
<title>Collections test</title>
 
4
<meta></meta>
 
5
</head>
 
6
<body>
 
7
 
 
8
<script type="text/javascript">
 
9
function Log (content, textblock, message)
 
10
{
 
11
textblock.printf (message);
 
12
        var run = content.createFromXaml ("<Run/>");
 
13
        run.text = message;
 
14
        
 
15
        if (textblock.inlines == null) {
 
16
                textblock.text = "";
 
17
        }
 
18
        
 
19
        textblock.inlines.add (run);
 
20
        run = content.createFromXaml ("<LineBreak/>");
 
21
        textblock.inlines.add (run);
 
22
}
 
23
 
 
24
function OnLoaded (sender, eventArgs)
 
25
{
 
26
        var control = document.getElementById ("agControl");
 
27
        var content = control.content;
 
28
        
 
29
        var canvas1 = content.findName ("canvas1");
 
30
        var canvas2 = content.findName ("canvas2");
 
31
        var log = content.findName ("log");
 
32
        var index, count;
 
33
        
 
34
        var xaml = "<Image Source='moonlight_logo.png'/>";
 
35
        var image = content.createFromXaml (xaml);
 
36
        
 
37
        // add the image to canvas1
 
38
        try {
 
39
                index = canvas1.children.add (image);
 
40
                Log (content, log, "canvas1.children.add (image) => PASS");
 
41
        } catch (err) {
 
42
                Log (content, log, "canvas1.children.add (image) => FAIL");
 
43
        }
 
44
        
 
45
        // try adding it to canvas1 again (should fail)
 
46
        try {
 
47
                index = canvas1.children.add (image);
 
48
                Log (content, log, "canvas1.children.add (image) => FAIL");
 
49
        } catch (err) {
 
50
                Log (content, log, "canvas1.children.add (image) => PASS");
 
51
        }
 
52
        
 
53
        // try inserting it into canvas1 again (should fail)
 
54
        try {
 
55
                index = canvas1.children.insert (0, image);
 
56
                Log (content, log, "canvas1.children.insert (0, image) => FAIL");
 
57
        } catch (err) {
 
58
                Log (content, log, "canvas1.children.insert (0, image) => PASS");
 
59
        }
 
60
        
 
61
        // try adding it to canvas2 (should fail)
 
62
        try {
 
63
                index = canvas2.children.add (image);
 
64
                Log (content, log, "canvas2.children.add (image) => FAIL");
 
65
        } catch (err) {
 
66
                Log (content, log, "canvas2.children.add (image) => PASS");
 
67
        }
 
68
}
 
69
</script>
 
70
 
 
71
<object type="application/x-silverlight" data="data:," id="agControl" width="100%" height="100%">
 
72
<param name="background" value="#FFFFFF"/>
 
73
<param name="source" value="#xamlContent"/>
 
74
</object>
 
75
 
 
76
<script type="text/xaml" id="xamlContent">
 
77
<?xml version="1.0"?>
 
78
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 
79
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 
80
        Loaded="OnLoaded">
 
81
 
 
82
  <Canvas x:Name="canvas1" Canvas.Left="5" Canvas.Top="5" Width="400" Height="195" Background="Red"/>
 
83
 
 
84
  <Canvas x:Name="canvas2" Canvas.Left="5" Canvas.Top="205" Width="400" Height="195" Background="Blue"/>
 
85
 
 
86
  <TextBlock x:Name="log" Canvas.Left="5" Canvas.Top="400" Width="400" TextWrapping="WrapWithOverflow"/>
 
87
</Canvas>
 
88
</script>
 
89
 
 
90
</body>
 
91
</html>