Click here to Skip to main content
15,892,768 members
Articles / Web Development / ASP.NET

Silverlight Pronunciation Test

Rate me:
Please Sign up or sign in to vote.
5.00/5 (12 votes)
29 Apr 2012CPOL11 min read 43.9K   1.7K   15  
How to create a pronunciation test tool using Silverlight and Python
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:PitchContour" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="PitchContour.MainPage"
             xmlns:controls="clr-namespace:PitchContour.Controls"
             xmlns:viewModels="clr-namespace:PitchContour.ViewModels"
    d:DesignHeight="452" d:DesignWidth="1100" mc:Ignorable="d" >

    <UserControl.DataContext>
        <viewModels:MainViewModel/>
    </UserControl.DataContext>

    <Grid x:Name="LayoutRoot">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="20"/>
                <RowDefinition Height="70"/>
                <RowDefinition Height="20"/>
                <RowDefinition Height="60"/>
                <RowDefinition Height="20"/>
                <RowDefinition Height="100"/>
                <RowDefinition Height="20"/>
                <RowDefinition Height="100"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="80"/>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="400"/>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="80"/>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="100"/>
            </Grid.ColumnDefinitions>
        
            <TextBlock Grid.Row="1" Grid.Column="2" Text="Pronunciation Test" FontSize="40" HorizontalAlignment="Center" VerticalAlignment="Center"/>
            <Grid Grid.Row="3" Grid.Column="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="60"/>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="60"/>
                </Grid.ColumnDefinitions>
                <controls:ArrowButton Grid.Column="0" Grid.Row="5" Height="60" Width="60" HorizontalAlignment="Center" Command="{Binding MovePreviousExerciseCommand}" IsEnabled="{Binding IsPreviousEnabled}">
                    <controls:ArrowButton.RenderTransform>
                        <ScaleTransform ScaleX="-0.75" ScaleY="0.75" CenterX="30" CenterY="30"/>
                    </controls:ArrowButton.RenderTransform>
                </controls:ArrowButton>
                <TextBlock Grid.Column="1" Text="{Binding SampleTitle}" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap"/>
                <controls:ArrowButton Grid.Column="2" Grid.Row="5" Height="60" Width="60" HorizontalAlignment="Center" Command="{Binding MoveNextExerciseCommand}" IsEnabled="{Binding IsNextEnabled}">
                    <controls:ArrowButton.RenderTransform>
                        <ScaleTransform ScaleX="0.75" ScaleY="0.75" CenterX="30" CenterY="30"/>
                    </controls:ArrowButton.RenderTransform>
                </controls:ArrowButton>
            </Grid>            
            <Grid Grid.Column="2" Grid.Row="5" Background="#eee">
                <Border x:Name="brdSampleVoiceCursor" BorderBrush="DarkGreen" BorderThickness="1" Height="100" Width="{Binding SampleVoiceMediaBorderWidth, Mode=TwoWay}"  HorizontalAlignment="Left" VerticalAlignment="Center">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Offset="0" Color="#fff"/>
                            <GradientStop Offset="0.5" Color="#8f8"/>
                            <GradientStop Offset="1" Color="#8f8"/>
                        </LinearGradientBrush>
                    </Border.Background>
                </Border>
                <Path x:Name="pthWave" Height="100" Width="500" Stroke="#aaa" Data="{Binding SampleVoiceWavePath}" HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="None"></Path>
                <Path x:Name="pthPitchCurve" Height="100" Width="500" Stroke="#f00" StrokeThickness="2" Data="{Binding SampleVoicePitchData}" HorizontalAlignment="Left" Stretch="None"></Path>
                <MediaElement x:Name="sampleVoiceMediaElement" Width="450" Height="250" Stretch="Fill" AutoPlay="True" Position="{Binding SampleVoiceMediaPosition, Mode=TwoWay}" MediaOpened="sampleVoiceMediaElement_MediaOpened"/>
            </Grid>
            <controls:ArrowButton Grid.Column="4" Grid.Row="5" Height="80" Width="80" HorizontalAlignment="Center" Command="{Binding PlaySampleVoiceCommand}"/>
        
            <controls:Microphone Grid.Column="0" Grid.Row="7" Height="80" Width="80" HorizontalAlignment="Center" Command="{Binding MicrophoneToggleCommand}"/>        
            <Grid Grid.Column="2" Grid.Row="7" Background="#eee">
                <Border x:Name="brdUserVoiceCursor" BorderBrush="DarkGreen" BorderThickness="1" Height="100" Width="{Binding UserVoiceMediaBorderWidth, Mode=TwoWay}"  HorizontalAlignment="Left" VerticalAlignment="Center">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Offset="0" Color="#fff"/>
                            <GradientStop Offset="0.5" Color="#8f8"/>
                            <GradientStop Offset="1" Color="#8f8"/>
                        </LinearGradientBrush>
                    </Border.Background>
                </Border>
                <Path x:Name="pthWave2" Height="100" Width="500" Stroke="#aaa" Data="{Binding UserVoiceWavePath}" HorizontalAlignment="Left" VerticalAlignment="Center" Stretch="None"></Path>
                <Path x:Name="pthPitchCurve2" Height="100" Width="500" Stroke="#f00" StrokeThickness="2" Data="{Binding UserVoicePitchData}" HorizontalAlignment="Left" Stretch="None"></Path>
                <MediaElement x:Name="userVoiceMediaElement" Width="450" Height="250" Stretch="Fill" AutoPlay="True" Position="{Binding UserVoiceMediaPosition, Mode=TwoWay}" MediaOpened="userVoiceMediaElement_MediaOpened"/>
            </Grid>
            <controls:ArrowButton Grid.Column="4" Grid.Row="7" Height="80" Width="80" HorizontalAlignment="Center" Command="{Binding PlayUserVoiceCommand}"/>

            <Grid Grid.Column="6" Grid.Row="3" Grid.RowSpan="5" Height="70">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock x:Name="txtGrade" Text="{Binding Grade}" Foreground="Green" FontSize="45" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
                <TextBlock Text="Points" Grid.Row="1" Foreground="Green" FontSize="20" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
            </Grid>

        </Grid>
    </Grid>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer Alura Cursos Online
Brazil Brazil

Comments and Discussions