예제 #1
0
        private void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                byte[] imageBytes = new byte[e.ChosenPhoto.Length];

                Guid guid = Guid.NewGuid();

                //editPersonViewModel.Person.FileName = string.Format("{0}\\{1}.jpg", "ProfilePicture", guid.ToString());

                string fileName = string.Format("{0}.jpg", guid.ToString());
                editPersonViewModel.Person.FileName = fileName;

                ImageInfo profilePic = new ImageInfo() { Directory = "ProfilePicture", FileName = string.Format("{0}.jpg", guid.ToString()), IsSquare = true, Height = 150, Width = 150 };
                ImageInfo thumbnail = new ImageInfo() { Directory = "ProfileThumbnail", FileName = string.Format("{0}.jpg", guid.ToString()), IsSquare = true, Height = 70, Width = 70 };

                Storage.WriteImageToIsolatedStorage(e.ChosenPhoto, new List<ImageInfo>() { profilePic, thumbnail });

                editPersonViewModel.Save();
            }
        }
예제 #2
0
        private void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                byte[] imageBytes = new byte[e.ChosenPhoto.Length];

                Guid guid = Guid.NewGuid();
                string fileName = string.Format("DatePicture\\{0}", guid.ToString());

                Photo p1 = new Photo() { DateId = ((DateViewModel)this.DataContext).Date.Id, Description = "Description", FileName = fileName, CreatedDate = DateTime.Now.ToString() };
                ((DateViewModel)this.DataContext).Ctx.Photos.InsertOnSubmit(p1);

                int ScreenWidth = Int32.Parse(System.Windows.Application.Current.Host.Content.ActualWidth.ToString());
                int ScreenHeight = Int32.Parse(System.Windows.Application.Current.Host.Content.ActualHeight.ToString());

                ImageInfo fullImage = new ImageInfo() { Directory = "DatePicture", FileName = string.Format("{0}.jpg", guid.ToString()), IsSquare = false, Height = ScreenHeight, Width = ScreenWidth };
                ImageInfo thumbnail = new ImageInfo() { Directory = "DatePicture", FileName = string.Format("{0}Small.jpg", guid.ToString()), IsSquare = true, Height = 136, Width = 136 };

                Storage.WriteImageToIsolatedStorage(e.ChosenPhoto, new List<ImageInfo>() { thumbnail, fullImage });

                //Storage.WriteImageToIsolatedStorage(e.ChosenPhoto, new List<ImageInfo>() { new ImageInfo() { Directory = "DatePicture", FileName = string.Format("{0}Small.jpg", guid.ToString()), Height = 136, Width = 136 } });

                ((DateViewModel)this.DataContext).Ctx.SubmitChanges();
            }
        }