private async Task _newFromPicture(StorageFile copyFile)
        {
            this.LoadingControl.State    = LoadingState.Loading;
            this.LoadingControl.IsActive = true;

            //Photo
            if (copyFile == null)
            {
                this.LoadingControl.State    = LoadingState.None;
                this.LoadingControl.IsActive = false;
                return;
            }
            Photo photo = await Photo.CreatePhotoFromCopyFileAsync(this.ViewModel.CanvasDevice, copyFile);

            Photo.DuplicateChecking(photo);

            //Transformer
            string      name              = this.MainLayout.UntitledRenameByRecursive($"{photo.Name}");
            int         width             = (int)photo.Width;
            int         height            = (int)photo.Height;
            Transformer transformerSource = new Transformer(width, height, Vector2.Zero);

            //ImageLayer
            Photocopier photocopier = photo.ToPhotocopier();
            ImageLayer  imageLayer  = new ImageLayer(this.ViewModel.CanvasDevice)
            {
                Transform   = new Transform(transformerSource),
                Photocopier = photocopier,
            };
            Layerage imageLayerage = imageLayer.ToLayerage();

            LayerBase.Instances.Add(imageLayer);

            //Project
            {
                Project project = new Project
                {
                    Name      = name,
                    Width     = width,
                    Height    = height,
                    Layerages = new List <Layerage>
                    {
                        imageLayerage
                    }
                };
                this.ViewModel.LoadFromProject(project);
            }

            //Transition
            TransitionData data = new TransitionData
            {
                Type = TransitionType.Size
            };

            this.LoadingControl.State    = LoadingState.None;
            this.LoadingControl.IsActive = false;
            this.Frame.Navigate(typeof(DrawPage), data);//Navigate
        }
        private async Task NewFromPictureCore(StorageFile copyFile)
        {
            this.LoadingControl.State = LoadingState.Loading;

            // Photo
            if (copyFile is null)
            {
                this.LoadingControl.State = LoadingState.None;
                return;
            }
            Photo photo = await Photo.CreatePhotoFromCopyFileAsync(LayerManager.CanvasDevice, copyFile);

            Photo.DuplicateChecking(photo);

            // Transformer
            string      name              = this.UntitledRenameByRecursive($"{photo.Name}");
            int         width             = (int)photo.Width;
            int         height            = (int)photo.Height;
            Transformer transformerSource = new Transformer(width, height, Vector2.Zero);

            // ImageLayer
            Photocopier photocopier   = photo.ToPhotocopier();
            Layerage    imageLayerage = Layerage.CreateByGuid();
            ImageLayer  imageLayer    = new ImageLayer
            {
                Id          = imageLayerage.Id,
                Transform   = new Transform(transformerSource),
                Photocopier = photocopier,
            };

            LayerBase.Instances.Add(imageLayerage.Id, imageLayer);

            // Project
            Project project = new Project
            {
                Width     = width,
                Height    = height,
                Layerages = new List <Layerage>
                {
                    imageLayerage
                }
            };

            // Item
            IProjectViewItem item = new ProjectViewItem
            {
                Name        = name,
                ImageSource = null,
                Project     = project,
            };

            this.Items.Insert(0, item);

            this.LoadingControl.State = LoadingState.None;
            this.Frame.Navigate(typeof(DrawPage), item); // Navigate
        }
Ejemplo n.º 3
0
        private async Task CopySingleImageFileAsync(IStorageItem item)
        {
            //Photo
            StorageFile copyFile = await FileUtil.CopySingleImageFileAsync(item);

            if (copyFile == null)
            {
                return;
            }
            Photo photo = await Photo.CreatePhotoFromCopyFileAsync(this.ViewModel.CanvasDevice, copyFile);

            Photo.DuplicateChecking(photo);
        }
Ejemplo n.º 4
0
        private async Task CopyMultipleImageFilesAndCreateImageLayersAsync(IReadOnlyList <IStorageItem> items)
        {
            if (items is null)
            {
                return;
            }

            // History
            LayeragesArrangeHistory history = new LayeragesArrangeHistory(HistoryType.LayeragesArrange_AddLayer);

            this.ViewModel.HistoryPush(history);

            IList <Layerage> imageLayerages = new List <Layerage>();

            foreach (IStorageItem item in items)
            {
                // Photo
                StorageFile copyFile = await FileUtil.CopySingleImageFileAsync(item);

                if (copyFile is null)
                {
                    continue;
                }
                Photo photo = await Photo.CreatePhotoFromCopyFileAsync(LayerManager.CanvasDevice, copyFile);

                Photo.DuplicateChecking(photo);

                if (photo is null)
                {
                    continue;
                }

                // Layer
                Layerage   imageLayerage = Layerage.CreateByGuid();
                ImageLayer imageLayer    = new ImageLayer(photo)
                {
                    Id         = imageLayerage.Id,
                    IsSelected = true,
                };
                LayerBase.Instances.Add(imageLayerage.Id, imageLayer);
                imageLayerages.Add(imageLayerage);
            }

            // Mezzanine
            LayerManager.MezzanineRange(imageLayerages);

            this.SelectionViewModel.SetMode(); // Selection
            LayerManager.ArrangeLayers();
            LayerManager.ArrangeLayersBackground();
            this.ViewModel.Invalidate(); // Invalidate
        }
Ejemplo n.º 5
0
        private async Task PickAndCopySingleImageFileAsync()
        {
            //Photo
            StorageFile copyFile = await FileUtil.PickAndCopySingleImageFileAsync(PickerLocationId.Desktop);

            if (copyFile == null)
            {
                return;
            }
            Photo photo = await Photo.CreatePhotoFromCopyFileAsync(this.ViewModel.CanvasDevice, copyFile);

            if (photo == null)
            {
                return;
            }
            Photo.DuplicateChecking(photo);
        }
Ejemplo n.º 6
0
        //////////////////////////


        // Gallery
        private void ConstructGalleryDialog()
        {
            this.GalleryDialog.SecondaryButtonClick += (s, e) => this.GalleryDialogTrySetResult(null, null);
            this.GalleryDialog.PrimaryButtonClick   += async(s, e) =>
            {
                // Files
                IReadOnlyList <StorageFile> files = await FileUtil.PickMultipleImageFilesAsync(PickerLocationId.Desktop);

                if (files is null)
                {
                    return;
                }

                foreach (StorageFile file in files)
                {
                    StorageFile copyFile = await FileUtil.CopySingleImageFileAsync(file);

                    if (copyFile is null)
                    {
                        continue;
                    }
                    Photo photo = await Photo.CreatePhotoFromCopyFileAsync(LayerManager.CanvasDevice, copyFile);

                    Photo.DuplicateChecking(photo);
                }
            };


            this.GalleryDialog.AllowDrop = true;
            this.GalleryDialog.Drop     += async(s, e) =>
            {
                if (e.DataView.Contains(StandardDataFormats.StorageItems))
                {
                    IReadOnlyList <IStorageItem> items = await e.DataView.GetStorageItemsAsync();

                    if (items is null)
                    {
                        return;
                    }

                    foreach (IStorageItem item in items)
                    {
                        // Photo
                        StorageFile copyFile = await FileUtil.CopySingleImageFileAsync(item);

                        if (copyFile is null)
                        {
                            continue;
                        }
                        Photo photo = await Photo.CreatePhotoFromCopyFileAsync(LayerManager.CanvasDevice, copyFile);

                        Photo.DuplicateChecking(photo);
                    }
                }
            };
            this.GalleryDialog.DragOver += (s, e) =>
            {
                e.AcceptedOperation = DataPackageOperation.Copy;
                //e.DragUIOverride.Caption = App.resourceLoader.GetString("DropAcceptable_");
                e.DragUIOverride.IsCaptionVisible = e.DragUIOverride.IsContentVisible = e.DragUIOverride.IsGlyphVisible = true;
            };
        }