Step 1

Download Visual Studio Community 2015 and install it onto your computer, if it’s already downloaded and installed select Launch to start Visual Studio Community 2015 or if it has already been downloaded and installed then start the application you may also need to Enable your device for development.

Step 2

Once Visual Studio Community 2015 has started select File, then New, then Project… from the Menu.

Step 3

From the New Project window select Visual C# from Installed, Templates then select Blank App (Windows Universal) from the list, then type in a Name and select a Location to save to before selecting Ok to create the Project.

Step 4

Once done select from the Menu, Project, then Add New Item…





Step 5

From the Add New Item window select Visual C# from Installed and select Code then select Code File from the list, then type in the Name as Library.cs before selecting Add to add the file to the Project

Step 6

Once in the Code View for Library.cs the following should be entered:

using System; using System.Collections.Generic; using System.Linq; using Windows.Foundation; using Windows.UI; using Windows.UI.Popups; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; public class Library { private int spins = 0; private int spinValue = 0; private int pickValue = 0; private Grid pocket; private Random random = new Random((int)DateTime.Now.Ticks); public void Show(string content, string title) { IAsyncOperation<IUICommand> command = new MessageDialog(content, title).ShowAsync(); } private bool isOdd(int value) { return (value % 2 != 0); } private void pick() { spins++; pocket.Children.Clear(); spinValue = random.Next(0, 36); // Random 0 - 36 Grid container = new Grid() { Height = 220, Width = 220 }; TextBlock text = new TextBlock() { Foreground = new SolidColorBrush(Colors.White), FontSize = 120, Text = spinValue.ToString(), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; Color fill; if (spinValue >= 1 && spinValue <= 10 || spinValue >= 19 && spinValue <= 28) { fill = isOdd(spinValue) ? Colors.Black : Colors.DarkRed; } else if (spinValue >= 11 && spinValue <= 18 || spinValue >= 29 && spinValue <= 36) { fill = isOdd(spinValue) ? Colors.DarkRed : Colors.Black; } else if (spinValue == 0) { fill = Colors.DarkGreen; } container.Background = new SolidColorBrush(fill); container.Children.Add(text); pocket.Children.Add(container); if (spinValue == pickValue) // Check Win { Show(("Spin " + spins + " matched " + spinValue), "Lucky Roulette"); spins = 0; } } private void layout(ref Grid grid) { grid.Children.Clear(); spins = 0; List<int> values = Enumerable.Range(0, 36).ToList(); StackPanel panel = new StackPanel(); pocket = new Grid() { Height = 220, Width = 220, HorizontalAlignment = HorizontalAlignment.Center }; ComboBox combobox = new ComboBox() { Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Center }; combobox.ItemsSource = values; combobox.SelectedIndex = 0; combobox.SelectionChanged += (object sender, SelectionChangedEventArgs e) => { pickValue = (int)((ComboBox)combobox).SelectedValue; }; panel.Children.Add(pocket); panel.Children.Add(combobox); grid.Children.Add(panel); } public void New(Grid grid) { layout(ref grid); } public void Pick(Grid grid) { if (pocket == null) layout(ref grid); pick(); } }

It should then appear as such:

Step 7

From the Solution Explorer select MainPage.xaml

Step 8

Select from the Menu, View then Designer

Step 9

The Design View will be displayed along with the XAML View and in this above <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”> enter the following XAML:

<Page.BottomAppBar> <AppBar IsOpen="True" IsSticky="True"> <StackPanel Orientation="Horizontal"> <AppBarButton Icon="Page" Label="New" Click="New_Click"/> <AppBarButton Icon="Accept" Label="Pick" Click="Pick_Click"/> </StackPanel> </AppBar> </Page.BottomAppBar>

While still in the XAML View below <Grid Background=”{ThemeResource ApplicationPageBackgroundThemeBrush}”> enter the following XAML:

<Grid Name="Display" HorizontalAlignment="Center" Height="300" Width="300"/>

It should appear as such:

Step 10

Select from the Menu, View then Code

Step 11

Once in the Code View below the public MainPage() { … } the following should be entered:

public Library Library = new Library(); private void New_Click(object sender, RoutedEventArgs e) { Library.New(Display); } private void Pick_Click(object sender, RoutedEventArgs e) { Library.Pick(Display); }

It should then appear as such:

Step 12

That completes the Universal Windows Application so Save the Project then select the Debug and Simulator option to run the Application

Step 13

Once the Simulator has started the Application should then appear

Step 14

After the Application has started running you can use New to start the Game then select a number from the list and choose Pick – if you get it right, you win!

Step 15

To Exit the application select Stop Debugging in Visual Studio Community 2015





Step 16

Another option is to run as a Windows 10 Mobile application, select Debug and select Emulator 10.0.10586.0 WVGA 4 inch 512MB option to run the Application

Step 17

Once the Emulator has started the Application should then appear





Step 18

After the Application has started running you can use New to start the Game then select a number from the list and choose Pick – if you get it right, you win!





Step 19

To Exit the application select Stop Debugging in Visual Studio Community 2015