private async void UpdateBtn_Click(object sender, RoutedEventArgs e) { // Update new Values to DB and go back to previous page _currentRoom.Surfaces[App.CurrSurface].Title = Title.Text; _currentRoom.Surfaces[App.CurrSurface].Description = Description.Text; if (_photo != null) { _currentRoom.Surfaces[App.CurrSurface].SurfaceImage = await CameraServices.ToByteArray(_photo); } DatabaseRepository.UpdateSurface(_currentRoom.Surfaces[App.CurrSurface]); // Save then go back Frame rootFrame = Window.Current.Content as Frame; if (rootFrame.CanGoBack) { //By recreating the page the image can be updated immediately(if you just used //go back once the image would not be visible before the first swipe). //The double go back is to avoid creating redundant copies on the stack. rootFrame.GoBack(); rootFrame.GoBack(); this.Frame.Navigate(typeof(CreateSurfacesPage), _currentRoom); } }
/* * Beautiful swiping functionality developed by Elvir and Nick of course, * It takes into consideration that a sweep wont be perfectly horizontal or * vertical. Oh, and yes it is a four way swipe. */ private void SwipeConfiguration() { int x1 = 0, x2 = 0, y1 = 0, y2 = 0, horizontal, vertical; ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY; ManipulationStarted += (s, e) => { x1 = (int)e.Position.X; y1 = (int)e.Position.Y; }; ManipulationCompleted += async(s, e) => { x2 = (int)e.Position.X; y2 = (int)e.Position.Y; horizontal = Math.Abs(x2 - x1); vertical = Math.Abs(y2 - y1); if (x1 > x2 && horizontal > vertical) { if (App.CurrSurface != 0) { App.CurrSurface--; } else { App.CurrSurface = 3; } } else if (x1 < x2 && horizontal > vertical) { if (App.CurrSurface < 3) { App.CurrSurface++; } else { App.CurrSurface = 0; } } else if (y1 > y2 && horizontal < vertical) { App.CurrSurface = 4; } else if (y1 < y2 && horizontal < vertical) { App.CurrSurface = 5; } // Surface name SwipeBlock.Text = SurfaceOptions.SurfaceSide(App.CurrSurface); // Update the current room _currentRoom = DatabaseRepository.GetRoom(_currentRoom.Title); // Converting from bytearray to BitmapImage and showing it. var img = await CameraServices.ToBitmapImage(_currentRoom.Surfaces[App.CurrSurface].SurfaceImage); SurfaceImage.Source = img; }; }
private async void CameraButton_Click(object sender, RoutedEventArgs e) { // Get camera and return a picture or null StorageFile photo = await _photoService.TakePicture(); if (photo != null) { // Convert display and save SurfaceImage.Source = await CameraServices.ToBitmapImage(photo); _photoService.SavePhoto(photo, _currentRoom, App.CurrSurface); } }
protected override async void OnNavigatedTo(NavigationEventArgs eventArgs) { if (eventArgs.Parameter != null) { _photoService = new CameraServices(); _currentRoom = (Room)eventArgs.Parameter; TitleBlock.Text = _currentRoom.Title; var b = _currentRoom.Surfaces[App.CurrSurface].SurfaceImage; var img = await CameraServices.ToBitmapImage(b); SurfaceImage.Source = img; } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { _currentRoom = (Room)e.Parameter; // Load Surface Title Title.Text = _currentRoom.Surfaces[App.CurrSurface].Title; // Load Description Description.Text = _currentRoom.Surfaces[App.CurrSurface].Description; // Load Image to description page BitmapImage img = await CameraServices.ToBitmapImage(_currentRoom.Surfaces[App.CurrSurface].SurfaceImage); SurfaceImage.Source = img; } }
private async void ExistingPhotoBtn_Click(object sender, RoutedEventArgs e) { StorageFile imageFile = await CameraServices.ExistingPhotosLibrary(); BitmapImage image = await CameraServices.ToBitmapImage(imageFile); if (image != null) { _photo = imageFile; // Show the image SurfaceImage.Source = image; // Add to the current room object // Update surface if you want to do without save button // DatabaseRepository.UpdateSurface(_currentRoom.Surfaces[App.CurrSurface]); } }
public CameraController(GameContext context, Services services) { _context = context; _cameraServices = services.CameraServices; }
public void Initialize(Contexts contexts) { PhysicsService = new PhysicsService(contexts); UnityTimeService = new UnityTimeService(contexts); CameraServices = new CameraServices(contexts); }