private void RedoRedEyeButtonClickHandler(object sender, RoutedEventArgs e)
        {
            if (_redEyeRemovalStep == 2)
            {
                if (_manualRedEyeIndex < _redEyeTransform.Transforms.Count)
                {
                    _manualRedEyeIndex++;
                    _redEyeBitmap.Redo();
                    _frame.Photo.Source         = PhotoItem.CreateBitmapSource(CreatePreviewBitmap(_redEyeBitmap, Aurigma.GraphicsMill.Transforms.ResizeMode.Fit));
                    _undoRedEyeButton.IsEnabled = _redEyeBitmap.CanUndo;
                    _redoRedEyeButton.IsEnabled = _redEyeBitmap.CanRedo;

                    _stepDescription.Text = (string)FindResource(Constants.ImageEditorRedEyeStep3TextKey);

                    if (_manualRedEyeIndex > 0)
                    {
                        _applyRedEyeButton.IsEnabled = true;
                    }
                }
            }
            else
            {
                throw new Exception("Internal state error. RedoRedEyeButtonClickHandler.");
            }
        }
        private void ManualRedEyeButtonClickHandler(object sende, RoutedEventArgs e)
        {
            _pointAdorner.Visibility       = Visibility.Visible;
            _pointAdorner.Point            = new Point(_frame.Photo.ActualWidth / 2, _frame.Photo.ActualHeight / 2);
            _removeRedEyeButton.Visibility = Visibility.Visible;
            _manualRedEyeButton.Visibility = Visibility.Collapsed;
            _nextRedEyeButton.Visibility   = Visibility.Collapsed;

            _applyRedEyeButton.IsEnabled = false;

            _redEyeBitmap.Undo();
            _transformIndex--;
            _redEyeBitmap.ClearHistory();
            _redEyeTransform.Transforms.Clear();
            _manualRedEyeIndex = 0;

            _undoRedEyeButton.IsEnabled = _redEyeBitmap.CanUndo;
            _redoRedEyeButton.IsEnabled = _redEyeBitmap.CanRedo;

            _stepDescription.Text = (string)FindResource(Constants.ImageEditorRedEyeStep3TextKey);

            _frame.Photo.MouseLeftButtonDown += new MouseButtonEventHandler(ManualRedEyeClickHandler);

            _frame.Photo.Source = PhotoItem.CreateBitmapSource(CreatePreviewBitmap(_redEyeBitmap, Aurigma.GraphicsMill.Transforms.ResizeMode.Fit));
            _redEyeRemovalStep  = 2;
        }
        private void RefreshPreview()
        {
            _undoButton.IsEnabled = _previewBitmap.CanUndo;
            _redoButton.IsEnabled = _previewBitmap.CanRedo;

            _frame.Photo.Source = PhotoItem.CreateBitmapSource(_previewBitmap);
            _frame.Update();
        }
        private void BlackWhiteEffectButtonClickHandler(object sender, RoutedEventArgs e)
        {
            _tmpBitmap = (Aurigma.GraphicsMill.Bitmap)_previewBitmap.Clone();
            _tmpBitmap.ColorAdjustment.Desaturate();
            _frame.Photo.Source = PhotoItem.CreateBitmapSource(_tmpBitmap);

            _applyEffectButton.IsEnabled = true;
            _effect = EffectTransforms.BlackAndWhite;
        }
        private void SepiaButtonClickHandler(object sender, RoutedEventArgs e)
        {
            _tmpBitmap = (Aurigma.GraphicsMill.Bitmap)_previewBitmap.Clone();
            _tmpBitmap.ColorAdjustment.Desaturate();
            Single[] objColorBalance = { 0F, 0.05F, 0.1F, 0F };
            _tmpBitmap.ColorAdjustment.ChannelBalance(objColorBalance);
            _frame.Photo.Source = PhotoItem.CreateBitmapSource(_tmpBitmap);

            _applyEffectButton.IsEnabled = true;
            _effect = EffectTransforms.Sepia;
        }
        private void BrightnessContrast()
        {
            if ((bool)_autoLevelsCheckBox.IsChecked)
            {
                _tmpBitmap = (Aurigma.GraphicsMill.Bitmap)_autoLevelsBitmap.Clone();
            }
            else
            {
                _tmpBitmap = (Aurigma.GraphicsMill.Bitmap)_previewBitmap.Clone();
            }

            _tmpBitmap.ColorAdjustment.BrightnessContrast(_brightnessAmount, _contrastAmount);
            _frame.Photo.Source = PhotoItem.CreateBitmapSource(_tmpBitmap);

            _applyColorButton.IsEnabled = true;
        }
        private void AutoLevelsButtonClickHandler(object sender, RoutedEventArgs e)
        {
            if (_brightnessAmount == 0 && _contrastAmount == 0)
            {
                if ((bool)_autoLevelsCheckBox.IsChecked)
                {
                    _frame.Photo.Source = PhotoItem.CreateBitmapSource(_autoLevelsBitmap);
                }
                else
                {
                    _frame.Photo.Source = PhotoItem.CreateBitmapSource(_previewBitmap);
                }

                _applyColorButton.IsEnabled = true;
            }
            else
            {
                BrightnessContrast();
            }
        }
        private void RemoveRedEyeButtonClickHandler(object sender, RoutedEventArgs e)
        {
            if (_redEyeRemovalStep == 2)
            {
                float x = (float)(_pointAdorner.Point.X * (_redEyeBitmap.Width / _frame.Photo.ActualWidth));
                float y = (float)(_pointAdorner.Point.Y * (_redEyeBitmap.Height / _frame.Photo.ActualHeight));

                var redEyePoint = new System.Drawing.PointF(x, y);

                if (_manualRedEyeIndex < _redEyeTransform.Transforms.Count)
                {
                    _redEyeTransform.Transforms[_manualRedEyeIndex] = new ManualRedEyeRemoval(_redEyeRect, redEyePoint);
                }
                else
                {
                    _redEyeTransform.Transforms.Add(new ManualRedEyeRemoval(_redEyeRect, redEyePoint));
                }
                _manualRedEyeIndex++;

                using (var manualModeTransform = new Aurigma.GraphicsMill.Transforms.RedEyeRemoval())
                {
                    manualModeTransform.Mode     = Aurigma.GraphicsMill.Transforms.RedEyeRemovalMode.Manual;
                    manualModeTransform.EyePoint = redEyePoint;
                    manualModeTransform.ApplyTransform(_redEyeBitmap);
                }

                _frame.Photo.Source = PhotoItem.CreateBitmapSource(CreatePreviewBitmap(_redEyeBitmap, Aurigma.GraphicsMill.Transforms.ResizeMode.Fit));

                _undoRedEyeButton.IsEnabled = _redEyeBitmap.CanUndo;
                _redoRedEyeButton.IsEnabled = _redEyeBitmap.CanRedo;

                _stepDescription.Text        = (string)FindResource(Constants.ImageEditorRedEyeStep3TextKey);
                _applyRedEyeButton.IsEnabled = true;
            }
            else
            {
                throw new System.Exception("Internal state error. RemoveRedEyeButtonClickHandler.");
            }
        }
        private void NextRedEyeButtonClickHandler(object sender, RoutedEventArgs e)
        {
            // The first step. Auto red eye removal
            if (_redEyeRemovalStep == 0)
            {
                _redEyeBitmap = (Aurigma.GraphicsMill.Bitmap)_sourceBitmap.Clone();
                if (!TransformBitmap(_redEyeBitmap))
                {
                    return;
                }

                _redEyeBitmap.UndoRedoEnabled = true;

                float x      = (float)(_rectangleAdorner.Rectangle.X * (_redEyeBitmap.Width / _frame.Photo.ActualWidth));
                float y      = (float)(_rectangleAdorner.Rectangle.Y * (_redEyeBitmap.Height / _frame.Photo.ActualHeight));
                float width  = (float)(_rectangleAdorner.Rectangle.Width * (_redEyeBitmap.Width / _frame.Photo.ActualWidth));
                float height = (float)(_rectangleAdorner.Rectangle.Height * (_redEyeBitmap.Height / _frame.Photo.ActualHeight));
                _redEyeRect = new System.Drawing.RectangleF(x, y, width, height);

                _redEyeBitmap.Transforms.Crop(_redEyeRect);

                _progressDialog = new ProgressDialog((string)ExecutionEngine.Instance.Resource[Constants.MessageTransformImageKey]);

                var workerThread = new Thread(new ParameterizedThreadStart(DoAutoRedEye));
                workerThread.Start((object)_redEyeBitmap);

                DateTime showDialogTime = DateTime.Now.AddSeconds(Constants.ProgressDialogTimeout);
                while (DateTime.Now.Second < showDialogTime.Second)
                {
                    if (_progressDialog.IsComplete)
                    {
                        break;
                    }
                }

                if (!_progressDialog.IsComplete)
                {
                    _progressDialog.ShowDialog();
                    if (!_progressDialog.DialogResult.Value)
                    {
                        return;
                    }
                }

                _redEyeTransform.Transforms.Add(new AutoRedEyeRemoval(_redEyeRect));
                RegisterTransform(_redEyeTransform);

                _frame.Photo.Source            = PhotoItem.CreateBitmapSource(CreatePreviewBitmap(_redEyeBitmap, Aurigma.GraphicsMill.Transforms.ResizeMode.Fit));
                _rectangleAdorner.Visibility   = Visibility.Collapsed;
                _pointAdorner.Visibility       = Visibility.Collapsed;
                _manualRedEyeButton.Visibility = Visibility.Visible;
                _applyRedEyeButton.IsEnabled   = true;
                _nextRedEyeButton.Visibility   = Visibility.Collapsed;
                _removeRedEyeButton.Visibility = Visibility.Collapsed;

                _stepDescription.Text = (string)FindResource(Constants.ImageEditorRedEyeStep2TextKey);

                _redEyeRemovalStep = 1;
            }
            else
            {
                throw new System.Exception("Internal state error. NextRedEyeButtonClickHandler");
            }
        }
Example #10
0
        private void TimerTickHandler(object sender, EventArgs e)
        {
            _elapsedTime += _timer.Interval.TotalMilliseconds;

            if (!_timer.IsEnabled || !_photosFound)
            {
                return;
            }

            // No files at all
            if (_files.Count == 0)
            {
                _isThreadAlive = false;
                _timer.Stop();

                if (_photosToRemove.Count != 0)
                {
                    ExecutionEngine.Context[Constants.PhotosToRemove] = _photosToRemove;
                }

                MessageDialog.Show((string)ExecutionEngine.Instance.Resource[Constants.MessageNoFilesFoundKey]);
                if (Engine.IsShowFolders)
                {
                    SwitchToSelectFoldersScreen();
                }
                else if (ExecutionEngine.Config.IsBluetoothEnabled())
                {
                    SwitchToSelectDeviceScreen();
                }
                else
                {
                    SwitchToWelcomeScreen();
                }
                return;
            }

            // No new files
            if (_photoItems.Count == 0)
            {
                _timer.Stop();
                _isThreadAlive = false;
                SwitchToSelectPhotos();
                return;
            }

            Bitmap exifSource = null;

            lock (_exifSources)
            {
                if (_exifSources.Count > 0)
                {
                    exifSource = _exifSources[0];
                    _exifSources.RemoveAt(0);
                }
            }

            if (exifSource != null)
            {
                _progressScreen.AddPreviewPhoto(PhotoItem.CreateBitmapSource(exifSource));
            }

            _progressScreen._progressBar.Value++;

            if (_elapsedTime >= ExecutionEngine.Config.SearchProcessDuration.Value)
            {
                _timer.Stop();
                _isThreadAlive = false;
                SwitchToSelectPhotos();
            }
        }