public bool Update(int colSpan, int rowSpan, int width, MagazineModel m) { bool needUpdateLayout = false; if (Title != m.Title) { Title = m.Title; } if (Subtitle != m.Subtitle) { Subtitle = m.Subtitle; } if (IsDownloaded != m.isDowloaded) { IsDownloaded = m.isDowloaded; var resourceLoader = new ResourceLoader(); if (m.isDowloaded) { DownloadOrReadButton = resourceLoader.GetString("read"); SampleOrDeleteButton = resourceLoader.GetString("delete"); Button1Tag = TAG_READ; Button2Tag = TAG_DEL; } else { DownloadOrReadButton = resourceLoader.GetString("download"); SampleOrDeleteButton = resourceLoader.GetString("sample"); if (!m.isDowloaded && !m.isPaid) { SecondButtonVisible = false; } else { SecondButtonVisible = true; } Button1Tag = TAG_DOWNLOAD; Button2Tag = TAG_SAMPLE; } } if (IsSampleDownloaded == m.isSampleDowloaded) { IsSampleDownloaded = m.isSampleDowloaded; } if (IsPaid != m.isPaid) { IsPaid = m.isPaid; } if (FileName != m.fileName) { FileName = m.fileName; } if (RelativePath != m.relativePath) { RelativePath = m.relativePath; } if (Thumbnail != String.Format("ms-appdata:///local/Covers/{0}", m.pngPath)) { needUpdateLayout = true; Thumbnail = String.Format("ms-appdata:///local/Covers/{0}", m.pngPath); } if (PngFile != m.pngPath) { PngFile = m.pngPath; } if (PngUrl != m.pngUrl) { PngUrl = m.pngUrl; } if (PngPath != m.assetsDir + m.pngPath) { PngPath = m.assetsDir + m.pngPath; } ColSpan = colSpan; RowSpan = rowSpan; var w = width; var h = 238; w *= ColSpan; h *= RowSpan; if (ColSpan > 1 && RowSpan > 1) { Thumbnail = Thumbnail.Replace(".png", "_newsstand.png"); PngFile = PngFile.Replace(".png", "_newsstand.png"); PngUrl = PngUrl.Replace(".png", "_newsstand.png"); w += 10; // * ColSpan; h += 10; // * RowSpan; } if (w != Width || h != Height) { needUpdateLayout = true; Width = w; Height = h; } //if (img != null) //{ // Image = img; //} //else //{ // Image = new BitmapImage(new Uri(String.Format("ms-appdata:///local/{0}", m.pngPath))); //} //Thumbnail = String.Format("ms-appdata:///local/{0}", m.pngPath); if (MagazineTag != m.fileName) { var resourceLoader = new ResourceLoader(); MagazineTag = m.fileName; } return(needUpdateLayout); }
//public MagazineViewModel(String uniqueId, String title, String subtitle, MagazineDataGroup group, string tumb, string b1, string b2) // : base(uniqueId, title, subtitle) //{ // Title = title; // Subtitle = subtitle; // Thumbnail=tumb; // DownloadOrReadButton=b1; // SampleOrDeleteButton=b2; // Button1Tag = "t1"; // Button2Tag = "t2"; // MagazineTag = "m1"; // this._group = group; //} public MagazineViewModel(String uniqueId, int colSpan, int rowSpan, int width, String title, String subtitle, MagazineDataGroup group, MagazineModel m) : base(uniqueId, title, subtitle) { _width = width; Title = m.Title; Subtitle = m.Subtitle; IsDownloaded = m.isDowloaded; IsSampleDownloaded = m.isSampleDowloaded; IsPaid = m.isPaid; FileName = m.fileName; RelativePath = m.relativePath; Thumbnail = String.Format("ms-appdata:///local/Covers/{0}", m.pngPath); PngFile = m.pngPath; PngUrl = m.pngUrl; PngPath = m.assetsDir + m.pngPath; SecondButtonVisible = true; Index = m.Index; ColSpan = colSpan; RowSpan = rowSpan; _width *= ColSpan; _height *= RowSpan; if (ColSpan > 1 && RowSpan > 1) { Thumbnail = Thumbnail.Replace(".png", "_newsstand.png"); PngFile = PngFile.Replace(".png", "_newsstand.png"); PngUrl = PngUrl.Replace(".png", "_newsstand.png"); _width += 10; // *ColSpan; _height += 10; // *RowSpan; } //if (img != null) //{ // Image = img; //} //else //{ // Image = new BitmapImage(new Uri(String.Format("ms-appdata:///local/{0}", m.pngPath))); //} //Thumbnail = String.Format("ms-appdata:///local/{0}", m.pngPath); var resourceLoader = new ResourceLoader(); MagazineTag = m.fileName; if (m.isDowloaded) { DownloadOrReadButton = resourceLoader.GetString("read"); SampleOrDeleteButton = resourceLoader.GetString("delete"); Button1Tag = TAG_READ; Button2Tag = TAG_DEL; } else { DownloadOrReadButton = resourceLoader.GetString("download"); SampleOrDeleteButton = resourceLoader.GetString("sample"); if (!m.isDowloaded && !m.isPaid) { SecondButtonVisible = false; } Button1Tag = TAG_DOWNLOAD; Button2Tag = TAG_SAMPLE; } this._group = group; }