Пример #1
0
        private void HandleRedraw(object sender, EventArgs args)
        {
            if (HoldRedraw)
            {
                redrawNeeded = true;
                return;
            }
//			System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace();
//			System.Diagnostics.Debug.WriteLine(st.ToString());

            CanvasPicture.Invalidate();             //this.Invalidate(true);
        }
        /// <summary>
        /// Invoked when an item is clicked.
        /// </summary>
        /// <param name="sender">The GridView (or ListView when the application is snapped)
        /// displaying the item clicked.</param>
        /// <param name="e">Event data that describes the item clicked.</param>
        async void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var project = ((CanvasProject)e.ClickedItem);

            if (project.Id == -1)
            {
                FileOpenPicker filePicker = new FileOpenPicker();
                filePicker.FileTypeFilter.Add(".png");
                filePicker.FileTypeFilter.Add(".jpg");
                filePicker.FileTypeFilter.Add(".jpeg");
                filePicker.ViewMode = PickerViewMode.Thumbnail;
                filePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                filePicker.SettingsIdentifier     = "imagePicker";
                filePicker.CommitButtonText       = "Select Files for Collage";
                IReadOnlyCollection <StorageFile> files = await filePicker.PickMultipleFilesAsync();

                if (files.Count > 0)
                {
                    project.ImagePath = files.First().Path;
                    project           = new CanvasProject
                    {
                        Name      = "NewCanvas.canvas",
                        FilePath  = files.First().Path,
                        ImagePath = files.First().Path + ".canvasimage",
                        Id        = -1
                    };
                    int count = 1;
                    project.Pictures = new List <CanvasPicture>();
                    foreach (var item in files)
                    {
                        CanvasPicture pict = new CanvasPicture
                        {
                            Id         = count++,
                            ImagePath  = item.Path,
                            SourceFile = item
                        };
                        project.Pictures.Add(pict);
                    }
                }
            }

            this.Frame.Navigate(typeof(SplitPage), project);
        }