Beispiel #1
0
        private void Initialize()
        {
            StatusTextBlock.Text = AppResources.MainPage_Status_InitializingCamera;

            _cameraEffect = new Effects {
                PhotoCaptureDevice = App.Camera, GlobalAlpha = 0.5
            };
            _cameraEffect.SetTexture(App.Texture.File);

            if (App.Texture.IsPositional)
            {
                DragHintText.Visibility  = Visibility.Visible;
                PinchHintText.Visibility = Visibility.Visible;

                _angle           = 0;
                _initialAngle    = 0;
                _scale           = DefaultScale;
                _position        = new Point(0.5, 0.5);
                _initialPosition = new Point(0.5, 0.5);

                RefreshTargetArea();
            }
            else
            {
                DragHintText.Visibility  = Visibility.Collapsed;
                PinchHintText.Visibility = Visibility.Collapsed;
            }

            LevelSlider.Value = 0.5;

            _cameraStreamSource = new CameraStreamSource(_cameraEffect, App.Camera.CaptureResolution);
            _cameraStreamSource.FrameRateChanged += CameraStreamSource_FPSChanged;

            _mediaElement = new MediaElement {
                Stretch = Stretch.UniformToFill, BufferingTime = new TimeSpan(0)
            };
            _mediaElement.SetSource(_cameraStreamSource);

            // Using VideoBrush in XAML instead of MediaElement, because otherwise
            // CameraStreamSource.CloseMedia() does not seem to be called by the framework:/

            BackgroundVideoBrush.SetSource(_mediaElement);

            StatusTextBlock.Text = _cameraEffect.EffectName;
        }
Beispiel #2
0
        /// <summary>
        /// If camera has not been initialized when navigating to this page, initialization
        /// will be started asynchronously in this method. Once initialization has been
        /// completed the camera will be set as a source to the VideoBrush element
        /// declared in XAML. On-screen controls are enabled when camera has been initialized.
        /// </summary>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (_photoCaptureDevice != null)
            {
                _photoCaptureDevice.Dispose();
                _photoCaptureDevice = null;
            }

            ShowProgress(AppResources.InitializingCameraText);
            await InitializeCamera(CameraSensorLocation.Back);

            HideProgress();
            BackgroundVideoBrush.SetSource(_photoCaptureDevice);

            SetScreenButtonsEnabled(true);
            SetCameraButtonsEnabled(true);
            Storyboard sb = (Storyboard)Resources["CaptureAnimation"];

            sb.Stop();

            SetOrientation(this.Orientation);

            base.OnNavigatedTo(e);
        }
Beispiel #3
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            NavigationContext.QueryString.TryGetValue("index", out _dateIndex);

            if (_photoCaptureDevice != null)
            {
                _photoCaptureDevice.Dispose();
                _photoCaptureDevice = null;
            }

            ProgressIndicator.IsRunning = true;
            SetScreenButtonsEnabled(false);
            SetCameraButtonsEnabled(false);

            await InitializeCamera(CameraSensorLocation.Back);

            BackgroundVideoBrush.SetSource(_photoCaptureDevice);

            ProgressIndicator.IsRunning = false;
            SetScreenButtonsEnabled(true);
            SetCameraButtonsEnabled(true);

            base.OnNavigatedTo(e);
        }
        private async void Initialize()
        {
            StatusTextBlock.Text = AppResources.MainPage_StatusTextBlock_StartingCamera;

            _cameraEffect = new Effects()
            {
                PhotoCaptureDevice = App.Camera
            };

            _cameraStreamSource = new CameraStreamSource(_cameraEffect, App.Camera.CaptureResolution);
            _cameraStreamSource.FrameRateChanged += CameraStreamSource_FPSChanged;

            _mediaElement = new MediaElement {
                Stretch = Stretch.UniformToFill, BufferingTime = new TimeSpan(0)
            };
            _mediaElement.SetSource(_cameraStreamSource);

            // Using VideoBrush in XAML instead of MediaElement, because otherwise
            // CameraStreamSource.CloseMedia() does not seem to be called by the framework:/

            BackgroundVideoBrush.SetSource(_mediaElement);

            StatusTextBlock.Text = _cameraEffect.EffectName;
        }