Silverlight/XAML – Learning by Coding
1: <?xml version="1.0" encoding="UTF-8"?>
2: <!-- coded by Thomas Meinike 02/08 -->
3: <Canvas xmlns="http://schemas.microsoft.com/client/2007"
4: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
5:
6: <Rectangle Canvas.Left="30" Canvas.Top="30" Width="656" Height="436"
7: Stroke="#00C" RadiusX="5" RadiusY="5"/>
8:
9: <MediaElement x:Name="audio" Source="media/d-kl_sound.mp3"
10: AutoPlay="True" MediaEnded="SoundNeustart"/>
11:
12: <MediaElement Canvas.Left="32" Canvas.Top="32"
13: x:Name="video" Width="652" Height="432"
14: Source="media/xamlcoder.wmv" AutoPlay="False"/>
15:
16: <Polygon x:Name="anfang" Points="30,490 30,510 40,510 40,490" Fill="#999"
17: MouseLeftButtonDown="BtnClick" MouseEnter="BtnOverOut" MouseLeave="BtnOverOut"/>
18:
19: <Polygon x:Name="start" Points="70,490 70,510 90,500" Fill="#090"
20: MouseLeftButtonDown="BtnClick" MouseEnter="BtnOverOut" MouseLeave="BtnOverOut"/>
21:
22: <Path x:Name="pause" Data="M120,490 H140 V510 H130 V490 H120 V510 H130"
23: Fill="#FFF" Stroke="#00C" StrokeThickness="1"
24: MouseLeftButtonDown="BtnClick" MouseEnter="BtnOverOut" MouseLeave="BtnOverOut"/>
25:
26: <Ellipse x:Name="stop" Canvas.Left="170" Canvas.Top="490" Width="20" Height="20" Fill="#C00"
27: MouseLeftButtonDown="BtnClick" MouseEnter="BtnOverOut" MouseLeave="BtnOverOut"/>
28:
29: <Polygon x:Name="ende" Points="220,490 220,510 230,510 230,490" Fill="#000"
30: MouseLeftButtonDown="BtnClick" MouseEnter="BtnOverOut" MouseLeave="BtnOverOut"/>
31:
32: <TextBlock Canvas.Left="560" Canvas.Top="490" FontFamily="Arial" FontSize="12"
33: Foreground="#999" Text="[Sound by Daniel Kling]"/>
34:
35:
36: <!-- // zusätzlich verwendeter JavaScript-Code:
37:
38: function BtnClick(sender,eventArgs)
39: {
40: var video=sender.findName("video");
41: var button=sender.name;
42:
43: if(button=="start")video.play();
44: else if(button=="pause")video.pause();
45: else if(button=="stop")video.stop();
46: else if(button=="anfang")video.position="00:00:00";
47: else if(button=="ende")video.position=video.naturalDuration;
48: }
49:
50:
51: function SoundNeustart(sender,eventArgs)
52: {
53: sender.findName("audio").position="00:00:00";
54: sender.findName("audio").play();
55: }
56:
57:
58: function BtnOverOut(sender,eventArgs)
59: {
60: var button=sender.name;
61: var op=sender.opacity;
62:
63: if(button=="start" || button=="pause" || button=="stop" || button=="anfang" || button=="ende")
64: {
65: if(op==1.0)sender.opacity=0.5;
66: else sender.opacity=1.0;
67: }
68: }
69:
70: -->
71:
72: </Canvas>
[zum Anfang]