+ All Categories
Home > Documents > Session 1

Session 1

Date post: 24-May-2015
Category:
Upload: anwar-yahyawi
View: 238 times
Download: 1 times
Share this document with a friend
Popular Tags:
20
Microsoft Leader club Session One – Dev Windows Phone 8 08/03/2013
Transcript
Page 1: Session 1

Microsoft Leader clubSession One – Dev Windows Phone 8

08/03/2013

Page 2: Session 1

APP CAMPUS

Page 3: Session 1

Get €50,000 for your Windows Phone app idea! The winner will also get a free trip to Finland to participate in a 4-week developer camp. Compete for the Worldwide Imagine Cup AppCampus Award! Top finalists incorporating a Windows Phone app into their project are eligible to win. Through this mobile application accelerator program, Microsoft and Nokia provide grants to fund innovative, first-to-market ideas with a fresh approach on design elegance, superior quality and performance

Page 4: Session 1
Page 5: Session 1

WINDOWS PHONE DEV CENTER

Page 6: Session 1

The Windows Phone Emulator

•The Windows Phone emulator runs as a Hyper-V virtual machine on your Windows PC • •It contains the same

software as a “real” phone, but built for the Windows PC platform

Page 7: Session 1

Page Navigation

Frame and Page •Frame •Top-level container control •PhoneApplicationFrame class •Contains the page control and system elements such as system tray and application bar •Page •Fills entire content region of the frame •PhoneApplicationPage-derived class •Contains a title •Optionally surfaces its own application bar

Page 8: Session 1

Using a Grid to Aid Landscape Layout

• <phone:PivotItem Header="recipe"> • <Grid> • <Grid.ColumnDefinitions> • <ColumnDefinition Width="*"/> • <ColumnDefinition Width="Auto"/> • </Grid.ColumnDefinitions> • <Grid.RowDefinitions> • <RowDefinition Height="Auto"/> • <RowDefinition Height="240"/> • <RowDefinition Height="*"/> • <RowDefinition Height="Auto"/> • </Grid.RowDefinitions> • ... • </Grid>

Page 9: Session 1

Handling Screen Orientation Changes Selecting Orientations

SupportedOrientations="Portrait« 

SupportedOrientations="PortraitOrLandscape« 

• •A XAML property for the phone application page lets you select the orientation options available

• •Your application can bind to an event which is fired when the orientation changes

Page 10: Session 1

Moving Elements

• private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e) { if (this.Orientation == PageOrientation.LandscapeLeft || this.Orientation == PageOrientation.LandscapeRight) { DirectionsScrollViewer.SetValue(Grid.RowProperty, 1); DirectionsScrollViewer.SetValue(Grid.ColumnProperty, 1); } else { DirectionsScrollViewer.SetValue(Grid.RowProperty, 2); DirectionsScrollViewer.SetValue(Grid.ColumnProperty, 0); } }

Page 11: Session 1

Page Navigation •XAML apps on Windows Phone use a page-based navigation model •Similar to web page model •Each page identified by a URI •Each page is essentially stateless

private void HyperlinkButton_Click_1( object sender, RoutedEventArgs e) { NavigationService.Navigate( new Uri("/SecondPage.xaml", UriKind.Relative)); }

Page 12: Session 1

Navigating Back •Application can provide controls to navigate back to preceding page

•The hardware Back key will also navigate back to preceding page •No code required – built-in behaviour

private void Button_Click_1( object sender, RoutedEventArgs e) { NavigationService.GoBack(); }

Page 13: Session 1

Passing Data Between Pages • •Can pass string data between pages using query

strings private void passParam_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/SecondPage.xaml?msg=" + textBox1.Text, UriKind.Relative)); }

• •On destination page protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); string querystringvalue = ""; if (NavigationContext.QueryString.TryGetValue("msg", out querystringvalue)) textBlock1.Text = querystringvalue; }

Page 14: Session 1

Isolated Storage Classes

• •The IsolatedStorage classes are all in the System.IO.IsolatedStorage namespace • •IsolatedStorageFile • •Represents an isolated storage area containing files and

directories • •IsolatedFileStream • •Exposes a file stream access to a file stored within isolated

storage • •IsolatedStorageSettings • •Dictionary<(Of <(TKey, TValue>)>) that stores key-value pairs

in isolated storage

Page 15: Session 1

Local Folder • •All read-write I/O operations restricted to local folder • •Create a files and folder structure hierarchy • •Use Isolated Settings storage to store application settings

Page 16: Session 1

Saving Data

private void saveGameToIsolatedStorage(string message) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream rawStream = isf.CreateFile("MyFile.store")) { StreamWriter writer = new StreamWriter(rawStream); writer.WriteLine(message); // save the message writer.Close(); } } }

Page 17: Session 1

Loading Data

private string loadString() { string result = null; using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { if (isf.FileExists("Myfile.store") { using (IsolatedStorageFileStream rawStream = isf.OpenFile(filename, System.IO.FileMode.Open)) { StreamReader reader = new StreamReader(rawStream); result = reader.ReadLine(); reader.Close(); } } } return result; }

Page 18: Session 1

Capture CameraCode XAML<Button x:Name="CaptureCameraButton" Content="Capture Camera" Width="300" Height="100" Margin="0,81,156,426" Click="CaptureCameraButton_Click" /><Image Height="150" HorizontalAlignment="Left" Margin="12,348,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="200" />Code c#private void CaptureCameraButton_Click(object sender, RoutedEventArgs e){CameraCaptureTask cct = new CameraCaptureTask();cct.Completed += new EventHandler<PhotoResult>(cct_Completed);cct.Show();}

void cct_Completed(object sender, PhotoResult e){BitmapImage bmp = new BitmapImage();bmp.SetSource(e.ChosenPhoto);image1.Source = bmp;}

Page 19: Session 1

Get PHOTOCode XAML• <Button x:Name="GetPhotoButton" Content="Get Photo" Width="300" Height="100" Margin="0,242,156,265"

Click="GetPhotoButton_Click" />• <Image Height="150" HorizontalAlignment="Left" Margin="12,348,0,0" Name="image2" Stretch="Fill"

VerticalAlignment="Top" Width="200" />

Code c#private void GetPhotoButton_Click(object sender, RoutedEventArgs e){PhotoChooserTask pct = new PhotoChooserTask();pct.Completed += new EventHandler<PhotoResult>(pct_Completed);pct.Show();}

void pct_Completed(object sender, PhotoResult e){BitmapImage bmp = new BitmapImage();bmp.SetSource(e.ChosenPhoto);image2.Source = bmp;}

Page 20: Session 1

Anwar YAHYAOUI•President du club Microsoft Leader•Email: [email protected]•Mobile: (+216) 24 23 41 73


Recommended