Exemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            _isCameraInitialized = false;
            _isTrial = new IsTrialQuery().Get();

            if (_isTrial)
            {
                var menuItem = new ApplicationBarMenuItem("Buy full version");
                menuItem.Click += (sender, args) => Deployment.Current.Dispatcher.BeginInvoke(() => new MarketplaceDetailTask().Show());
                ApplicationBar.MenuItems.Add(menuItem);
            }

            OnOrientationChanged(this, new OrientationChangedEventArgs(Orientation));

            if (PhotoCamera.IsCameraTypeSupported(CameraType.Primary))
            {
                _pixelator = new Pixelator(new PixelationSizeQuery().Get(), true);

                _photoCamera = new PhotoCamera(CameraType.Primary);
                _photoCamera.Initialized += OnCameraInitialized;
                _photoCamera.CaptureImageAvailable += OnCameraCaptureImageAvailable;
                _photoCamera.CaptureCompleted += OnCameraCaptureCompleted;
                _photoCamera.CaptureStarted += OnCameraCaptureStarted;

                ViewfinderBrush.SetSource(_photoCamera);
            }
            else
            {
                // TODO: handle possibility of no camera
            }
        }
Exemplo n.º 2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (pixelatedImage.Source == null && e.IsNavigationInitiator)
            {
                var task = new PhotoChooserTask();
                task.Completed += OnPhotoChooserTaskCompleted;
                task.ShowCamera = true;
                task.Show();
            }

            if (pixelationListBox.Items.Count == 0)
            {
                pixelationListBox.Items.Add(3);
                pixelationListBox.Items.Add(4);
                pixelationListBox.Items.Add(5);
                pixelationListBox.Items.Add(6);
                pixelationListBox.Items.Add(7);
                pixelationListBox.Items.Add(8);
                pixelationListBox.Items.Add(9);
                pixelationListBox.Items.Add(10);
            }

            var pixelateSize = new PixelationSizeQuery().Get();
            pixelationListBox.SelectedItem = pixelateSize; // TODO: don't work
            pixelationListBox.SelectionChanged += OnPixelationListBoxSelectionChanged;
            _pixelator = new Pixelator(pixelateSize, false);

            sliderDebug.ValueChanged += OnSliderDebugValueChanged;
        }
Exemplo n.º 3
0
        public void GivenAPixelatorWithPixelSizeEight()
        {
            _pixelator = new Pixelator(2, true);

            var buffer = new[]
                             {
                                 0, 1, 2, 3, 4, 5, 6, 7,
                                 8, 9, 10, 11, 12, 13, 14, 15,
                                 16, 17, 18, 19, 20, 21, 22, 23,
                                 24, 25, 26, 27, 28, 29, 30, 31,
                                 32, 33, 34, 35, 36, 37, 38, 39,
                                 40, 41, 42, 43, 44, 45, 46, 47,
                                 48, 49, 50, 51, 52, 53, 54, 55,
                                 56, 57, 58, 59, 60, 61, 62, 63
                             };

            var result = _pixelator.Pixelate(buffer, 8, 8);

            var expectedBuffer = new[]
                             {
                                 12, 13, 14, 15, 12, 13, 14, 15,
                                 12, 13, 14, 15, 12, 13, 14, 15,
                                 28, 29, 30, 31, 28, 29, 30, 31,
                                 28, 29, 30, 31, 28, 29, 30, 31,
                                 44, 45, 46, 47, 44, 45, 46, 47,
                                 44, 45, 46, 47, 44, 45, 46, 47,
                                 60, 61, 62, 63, 60, 61, 62, 63,
                                 60, 61, 62, 63, 60, 61, 62, 63
                             };

            Assert.AreEqual(expectedBuffer, result);
        }