Likes

Windows App Lab@Home 3

4. Steve has to develop a windows Store app for displaying the various dishes available in a restaurant. The expected interfece of the app is shown in the following figure.

4. Steve has to develop a windows Store app for displaying the various dishes available in
   a restaurant. The expected interfece of the app is shown in the following figure.

Solution;

(XAML Code)

      <Grid Background="#FFD007F0">
          <ListView x:Name="lst" HorizontalAlignment="Left" Height="688" Margin="64,46,0,0" VerticalAlignment="Top" Width="337" FontSize="24" SelectionChanged="lst_SelectionChanged">
     
          </ListView>
          <Viewbox>
              <StackPanel x:Name="stk" Orientation="Vertical" Margin="722,10,100,34" Width="458">
                  <Image X:Name="img" Source="" HorizontalAlignment="Left" Margin="20,20,0,20" VerticalAlignment="Top"/>

    ======================================================================


(CCS Code)


     Privete void lst_SelectionChanged(object sender, SelectionChangedEventArgs)
      {
           if (lst.SelectedItem.ToString()=="Burger")
           {
               img.Source = new BitmapImage(New Uri("as-appx:///Assets/Burger.jpg"));
               head.Text = "Burger";
               para.Text = "Fresh juicy ham burgers at a pocket-friendly price of";
           }
           else if (lst.SelectedItem.ToString()=="Cheese Sandwich")
           {
             
               img.Source = new BitmapImage(New Uri("as-appx:///Assets/Cheese Sandwich.jpg"));
               head.Text = "Cheese Sandwich";
               para.Text = "Mouth-watering Cheese Sandwichs at a price of 2$";
           }
           else if (lst.SelectedItem.ToString()=="Noodles")
            {
             
               img.Source = new BitmapImage(New Uri("as-appx:///Assets/Noodles.jpg"));
               head.Text = "Noodles";
               para.Text = "Traditional Asian Noodles at a price of 3$";
           }
            else if (lst.SelectedItem.ToString()=="pasta salad")
            {
             
               img.Source = new BitmapImage(New Uri("as-appx:///Assets/Pasta salad.jpg"));
               head.Text = "Pasta salad";
               para.Text = "Zesty summary Pasta salad at a very low price of 2$";
           }
             else if (lst.SelectedItem.ToString()=="Pizze")
             {
             
               img.Source = new BitmapImage(New Uri("as-appx:///Assets/Pizze.jpg"));
               head.Text = "Pizze";
               para.Text = "Lip amacking classic Pizze at a rate of 5$";
           }
      }








2. sam,a Windows store app developer, wants to create a simple app for children. He expects the interface of the piano to look like the one shown in following figure.

2. sam,a Windows store app developer, wants to create a simple app for children. He expects
   the interface of the piano to look like the one shown in following figure.

Solution;

(XAML Code)

 
      <Grid.RowDefinitions>
        <RowDefinition height="400"></RowDefinition>
        <RowDefinition height=""></RowDefinition>
      <Grid Grid.Column="0" margin="0,280,0,0" Grid.RowSpan="3">
       <Grid X:Name="grdChordButtons" Tapped="grdChordButtons_Tapped">
           <Grid.RowDefinitions>
             <RowDefinition></RowDefinition>
             </Grid.RowDefinitions>
             <Grid.ColumnDefinitions>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
             <ColumnDefinition></ColumnDefinition>
             </Grid.ColumnDefinitions>
             <Button Background="White" x:Name="C" fontSize="60" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"></Button>
             <Button Background="White" x:Name="D" fontSize="60" Grid.Column="1"HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"></Button>
             <Button Background="White" x:Name="E" fontSize="60" Grid.Column="2"HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"></Button>
             <Button Background="White" x:Name="F" fontSize="60" Grid.Column="3"HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"></Button>
             <Button Background="White" x:Name="G" fontSize="60" Grid.Column="4"HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"></Button>
             <Button Background="White" x:Name="A" fontSize="60" Grid.Column="5"HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"></Button>
             <Button Background="White" x:Name="B" fontSize="60" Grid.Column="6"HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"></Button>
             <Button Background="White" x:Name="C" fontSize="60" Grid.Column="7"HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0"></Button>
         </Grid>
         <Grid x:Name="grdBlackChordButtons" Height="320" VerticalAlignment="Top" Margin="95,0,86,0" Tapped="grdBlackChordButtons_Tapped">
         <Grid.RowDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>


========================================================================


(CCS Code)

    privete void grdChordButtons_Tapped(object sender, TappedRoutedEventArgs e)
    {
       UIElement controls = e.OriginalSource as UIEement;
       Button bttnChord = null;
       While (controls != null && controls !=sender as UIEement)
    }
        if(controls is Button)
         {
             bttnChord = controls as Button;
             break;
         }
         controls = VisualTreeHelper.GetParent(controls) as UIEement;
    }
     if (bttnChord !=null)
    {
     PianoChordPlayer.Source new Uri("as-appx:///Assets/" + bttnChord.Name + "wav");
     PianoChordPlayer.Play();
    }
}

privete void grdChordButtons_Tapped(object sender, TappedRoutedEventArgs e)
    {
       UIElement controls = e.OriginalSource as UIEement;
       Button bttnChord = null;
       While (controls != null && controls !=sender as UIEement)
    }
        if(controls is Button)
         {
             bttnChord = controls as Button;
             break;
         }
         controls = VisualTreeHelper.GetParent(controls) as UIEement;
    }
     if (bttnChord !=null)
    {
     string bttnName = bttnChord.Name;
     PianoChordPlayer.Source new Uri("as-appx:///Assets/" + bttnChord.Name + "wav");
     PianoChordPlayer.Play();
    }






3. Rhea has designeed an app that should convet the temperature specified in Celsius to the corresponding temperature in Fahrenheit and vice versa. The interface of the app is shown in the following figure.

3. Rhea has designeed an app that should convet the temperature specified in Celsius to the
   corresponding temperature in Fahrenheit and vice versa. The interface of the app is shown in the
   following figure.

Solution;

 (XAML Code)
 
       <Viewbox>
         <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Height="900" Width="1600">
         <TextBlock Text="Celsius" FontSize="100" margin="122,122,1002,668"></Textbox>
         <TextBox X:Name="txtDegreeCelsius" FontSize="70" Margin="122,257,121,654" KeyUp="tetDegreeCelsius_KeyUp"></TextBox>
         <TextBlock Text="Fahreenheit" FontSize="100" margin="122,463,931,326"/>
         <TextBox X:Name="txtDegreeFahreenheit" FontSize="70" Margin="122,257,121,209"KeyUp="tetDegreeFahrenheit_KeyUp"/>
     </Grid>
========================================================================
     
(CCS Code)

       Privete void txtDegreeCelsius_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            try
             {
                 if (!string.IsNullOrEmpty(txtDegreeCelsius.Text.Trim()))
                     txtDegreeFahreheit.Text = (Convert.Todouble(txtDegreeCelsius.Text.Trim()))
                 else
                     txtDegreeFahrenheit.Text = "";
             }
             catch (Exception ex)
             {
                  txtDegreeFahrenheit.Text = "Invalid input";
             }
        }
     
   
       Privete void txtDegreeCelsius_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            try
             {
                 if (!string.IsNullOrEmpty(txtDegreeCelsius.Text.Trim()))
                     txtDegreeFahreheit.Text = (Convert.Todouble(txtDegreeCelsius.Text.Trim()))
                 else
                     txtDegreeFahrenheit.Text = "";
             }
             catch (Exception ex)
             {
                  txtDegreeFahrenheit.Text = "Invalid input";
             }
        }







1. John is developing a windows store Store app for viewing images. He has created the UI of the app, as shown in the following figure.

1. John is developing a windows store Store app for viewing images. He has created the UI of the app,
   as shown in the following figure.


Solution;


(XAML Code)


     <ViewBox>
    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Content="Image List" HorizontalAlignment="Left" Mergin="10,10,0,0" BorderThickness="0" FontSize="24" Backround="Blue" VerticalAlignment="Top" Width="315"/>
                <ListBox N:Name="IstboxPictureList" HorizontalAlignment="Left" Height="697" Margin="10,61,0,0"  VerticalAlignment="Top" width="315" SelectionChanged="IstboxPictureList_SelectionChanged"/>

                <Button Content="Image Preview" HorizontalAlignment="Left" Mergin="346,10,0,0" BorderThickness="0" FontSize="24" Background="Blue"  VerticalAlignment="Top" Width="1010"/>
            <Button IsEnabled="False" HorizontalAlignment="Left" Height="697" Margin="346,10,0,0"  VerticalAlignment="Top" Width="1010" />
        <Image x:Name="imgPreview" Source="Assets/1.jpg"  Stretch="Uniform"></Image>
        </Button>
    </ViewBox>


========================================================================
(CCS Code)


using Windows.UI.Xaml.Media.Imaging;


/// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
        }

private void InitializeComponent()
{
  throw new NotImplementedException();
}

        public void loadPictureList();
    {
        for (int i=1; i < 9; i++)
    {
        IstboxPictureList.SelectedIndexz = 0;
    }
    }
   ///////////////     private void IstboxPictureList_selectionChanged(object, SelectionChangedEventArgs);
    {
        imgPreview.Source = new BitmapImage("as-appx:///Assets/"+lst)
    }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
loadPictureList();
        }
    }
}

No comments: