public PersonViewModel(int personId, PhoneApplicationPage page) : base(page) { this.Person = Ctx.Persons.SingleOrDefault(x => x.Id == personId); if (!String.IsNullOrEmpty(this.Person.FileName)) { this.Person.Image = Storage.ReadImageFromIsolatedStorageToWriteableBitmap(string.Format("ProfilePicture\\{0}", this.Person.FileName)); //GeneralMethods.ResizeImageToThumbnail(Storage.ReadImageFromIsolatedStorageAsStream(this.Person.FileName), 150); } else { this.Person.Image = Storage.ReadImageFromContent("./Images/ChoosePhoto.jpg"); } foreach (Date date in this.Person.Dates) { ChronoGrouping.MarkDate(date); } this.GroupedDateList = (from obj in this.Person.Dates orderby(int) obj.ChronoGroupKey ascending, obj.DateOfMeeting ascending group obj by obj.ChronoGroupKey.ToDescription() into grouped select new Grouping <string, Date>(grouped)).ToList(); Interests = (from i in Ctx.Interests select new { Description = i.Description, FontSize = i.Weighting * 15, Interest = i }).AsEnumerable() .Select(t => new TagCloudItem() { Description = t.Description, FontSize = t.FontSize, Margin = new System.Windows.Thickness { Top = GetRandomInt(1, 20, t.FontSize / 15), Left = 10, Right = 10 }, Interest = t.Interest }).ToList(); }
public HomeViewModel(PhoneApplicationPage page) : base(page) { Repository <Person> repPerson = new Repository <Person>(Ctx); Repository <Date> repDate = new Repository <Date>(Ctx); Repository <Venue> repVenue = new Repository <Venue>(Ctx); this.People = new ObservableCollection <Person>(repPerson.GetAll()); this.Dates = new ObservableCollection <Date>(repDate.GetAll()); this.Venues = new ObservableCollection <Venue>(repVenue.GetAll()); this.TileItems = new List <TileItem>() { new TileItem() { Title = "People", Message = ResolveTileInfo(this.People.Count(x => x.IsFavourite == true)), ImageUri = "/Images/PeopleCollage.jpg" }, new TileItem() { Title = "Dates", Message = ResolveTileInfo(this.Dates.Count(x => x.IsFavourite == true)), ImageUri = "/Images/WineGlassTmp.jpg" }, new TileItem() { Title = "Venues", Message = ResolveTileInfo(this.Venues.Count(x => x.IsFavourite == true)), ImageUri = "/Images/VenuesTmp.jpg" } }; foreach (Date date in this.Dates.Where(x => x.DateOfMeeting.Date >= DateTime.Now.Date).Take(10)) { ChronoGrouping.MarkDate(date); } foreach (Person person in this.People) { person.Image = Storage.ReadImageFromIsolatedStorageToWriteableBitmap(string.Format("ProfileThumbnail\\{0}", person.FileName)); //if (!String.IsNullOrEmpty(person.FileName)) // Storage.AsyncImageLoad(person.FileName, person); //Stream stream = Storage.ReadImageFromIsolatedStorageAsStream(person.FileName); //person.Image = stream == null ? Storage.ReadImageFromContent("./Images/LittleDude.jpg") : GeneralMethods.ResizeImageToThumbnail(stream, 150); } //person.Image = GeneralMethods.ResizeImageToThumbnail(Storage.ReadImageFromIsolatedStorageAsStream(person.FileName), 50); this.GroupedPersonList = (from obj in this.People orderby obj.FirstName ascending group obj by obj.FirstName.ToUpper().ToList().First() into grouped select new Grouping <char, Person>(grouped)).ToList(); this.GroupedDateList = (from obj in this.Dates.Where(x => x.DateOfMeeting.Date >= DateTime.Now.Date) orderby(int) obj.ChronoGroupKey ascending, obj.DateOfMeeting ascending group obj by obj.ChronoGroupKey.ToDescription() into grouped select new Grouping <string, Date>(grouped)).ToList(); }