protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { // Initialize the camera, when available. camera = new PhotoCamera(); // Event is fired when the PhotoCamera object has been initialized. camera.Initialized += new EventHandler<CameraOperationCompletedEventArgs>(cam_Initialized); //Set the VideoBrush source to the camera. viewfinderBrush.SetSource(camera); } void cam_Initialized(object sender, CameraOperationCompletedEventArgs e) { if (e.Succeeded) { this.Dispatcher.BeginInvoke(delegate() { MessageBox.Show("Camera initialized."); }); } } protected override void OnOrientationChanged(OrientationChangedEventArgs e) { if (camera != null) { // LandscapeRight rotation when camera is on back of phone. int landscapeRightRotation = 180; // Change LandscapeRight rotation for front-facing camera. if (camera.CameraType == preferences.CameraDevice.Value) landscapeRightRotation = -180; // Rotate video brush from camera. if (e.Orientation == PageOrientation.LandscapeRight) { // Rotate for LandscapeRight orientation. viewfinderBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation }; } else { // Rotate for standard landscape orientation. viewfinderBrush.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 0 }; } } base.OnOrientationChanged(e); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)