public void SetImage(BitmapSource source, BoxArtFrame frame, Export parent)
 {
     CropControl.SetImage(source, frame.Width, frame.Height);
     CropControl.Callback = RenderFrames;
     _parent = parent;
     _source = source;
     _frame  = frame;
     RenderFrames();
 }
 public void Init()
 {
     Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
         CoreDispatcherPriority.Normal,
         () =>
     {
         _app = PocketPaintApplication.GetInstance();
         new PaintingAreaView();
         //app.CropControl = new CropControl();
         _sut = _app.CropControl;
     });
     while (_sut == null)
     {
     }
 }
Exemple #3
0
        public static void EditPhoto(Action <byte[]> callback)
        {
            var photoPickerSettings = IoC.Get <IStateService>().GetPhotoPickerSettings();

            if (photoPickerSettings != null && photoPickerSettings.External)
            {
                var photoChooserTask = new PhotoChooserTask
                {
                    ShowCamera  = true,
                    PixelHeight = 800,
                    PixelWidth  = 800
                };

                photoChooserTask.Completed += (o, e) =>
                {
                    if (e.TaskResult == TaskResult.OK)
                    {
                        byte[] bytes;
                        var    sourceStream = e.ChosenPhoto;
                        using (var memoryStream = new MemoryStream())
                        {
                            sourceStream.CopyTo(memoryStream);
                            bytes = memoryStream.ToArray();
                        }
                        callback.SafeInvoke(bytes);
                    }
                };

                photoChooserTask.Show();
            }
            else
            {
                ChooseAttachmentViewModel.OpenPhotoPicker(true, (result1, result2) =>
                {
                    Execute.BeginOnUIThread(TimeSpan.FromSeconds(0.4), () =>
                    {
                        var frame = Application.Current.RootVisual as PhoneApplicationFrame;
                        PhoneApplicationPage page = null;
                        if (frame != null)
                        {
                            page = frame.Content as PhoneApplicationPage;
                            if (page != null)
                            {
                                var applicationBar = page.ApplicationBar;
                                if (applicationBar != null)
                                {
                                    applicationBar.IsVisible = false;
                                }
                            }
                        }

                        if (page == null)
                        {
                            return;
                        }

                        var popup       = new Popup();
                        var cropControl = new CropControl
                        {
                            Width  = page.ActualWidth,
                            Height = page.ActualHeight
                        };
                        _cropControl      = cropControl;
                        page.SizeChanged += PageOnSizeChanged;

                        cropControl.Close += (sender, args) =>
                        {
                            _cropControl = null;
                            popup.IsOpen = false;
                            popup.Child  = null;

                            frame = Application.Current.RootVisual as PhoneApplicationFrame;
                            if (frame != null)
                            {
                                page = frame.Content as PhoneApplicationPage;
                                if (page != null)
                                {
                                    page.SizeChanged  -= PageOnSizeChanged;
                                    var applicationBar = page.ApplicationBar;
                                    if (applicationBar != null)
                                    {
                                        applicationBar.IsVisible = true;
                                    }
                                }
                            }
                        };
                        cropControl.Crop += (sender, args) =>
                        {
                            callback.SafeInvoke(args.File);

                            cropControl.TryClose();
                        };
                        cropControl.SetFile(result1.FirstOrDefault(), result2.FirstOrDefault());

                        popup.Child  = cropControl;
                        popup.IsOpen = true;
                    });
                });
            }
        }
 public void CleanUp()
 {
     _sut = null;
     _app = null;
 }