public async Task GetImage(string filename, string foldername, Image image, bool wait) { try { StorageFolder folder; if (foldername == null) { folder = await KnownFolders.VideosLibrary.GetFolderAsync("AppAssets"); } else { folder = await KnownFolders.VideosLibrary.GetFolderAsync("AppAssets\\" + foldername); } StorageFile file = await folder.GetFileAsync(filename); var stream = await file.OpenAsync(FileAccessMode.Read); image.Visibility = Visibility.Visible; BitmapImage bitmapImage = new BitmapImage(); image.Source = bitmapImage; await bitmapImage.SetSourceAsync(stream); if (wait == true) { GetTimer.DispatcherTimerExtend(staticImageWaitTime); } } catch (Exception ex) { try { StorageFolder folder; if (foldername == null) { folder = await KnownFolders.VideosLibrary.GetFolderAsync("AppAssets"); } else { folder = await KnownFolders.VideosLibrary.GetFolderAsync("AppAssets\\" + foldername); } StorageFile file = await folder.GetFileAsync("x.png"); var stream = await file.OpenAsync(FileAccessMode.Read); image.Visibility = Visibility.Visible; BitmapImage bitmapImage = new BitmapImage(); image.Source = bitmapImage; await bitmapImage.SetSourceAsync(stream); } catch (Exception ex2) { if (ex2 is FormatException) { image.Visibility = Visibility.Collapsed; } } } }
private void Bottom_Button_GotFocus(object sender, RoutedEventArgs e) { GetSerialDevice.ShowBottomDpad(); GetTimer.DispatcherTimerExtend(GetTimer.defaultIdleTime); }
private void Right_Button_GotFocus(object sender, RoutedEventArgs e) { GetSerialDevice.ShowRightDpad(); GetTimer.DispatcherTimerExtend(GetTimer.defaultIdleTime); Show_Answer(3); }