예제 #1
0
        private void Setup()
        {
            viewModel        = new MotionDetectorViewModel();
            this.DataContext = viewModel;

            // As much as I hate doing this, we have to inject the capture element control becase
            // the MediaCapture object can't initialize until it has a "Sink" (the capture element)
            // to dump images into. However, if you just bind to it, it attempts to initialize
            // prior to binding. Chicken and egg problem.
            //
            // The alternative was to create a ContentControl and bind to a CaptureElement maintained
            // in the viewmodel. This sounds worse than just injecting it into the setup function.
            viewModel.Setup(captureElementControl);
        }
        //*****************************************************************************//

        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is bool showRateReminder && !showRateReminder)
            {
                rateReminder = null;
            }

            App.Current.LeavingBackground += Current_LeavingBackground;
            App.Current.EnteredBackground += Current_EnteredBackground;
            this.DataContextChanged       += DashboardPage_DataContextChanged;
            MotionDetectorViewModel viewModel = new MotionDetectorViewModel();

            this.DataContext = viewModel;

            await viewModel.Setup();

            viewModel.caputureSink.HorizontalAlignment = HorizontalAlignment.Stretch;
            this.captureElementControl.Content         = viewModel.caputureSink;

            if (StoreServices.IsPremium)
            {
                AlertButton.Visibility = Visibility.Visible;
            }
        }