protected override async void ItemChanged() { // setup our image... var manager = new ReportImageCacheManager(); await this.Item.InitializeAsync(manager); }
internal static async Task <ReportItem> CreateReportItemAsync(string title, string description, IMappablePoint point, IStorageFile image) { var item = new ReportItem() { Title = title, Description = description, NativeId = Guid.NewGuid().ToString(), Status = ReportItemStatus.New }; item.SetLocation(point); // save... var conn = StreetFooRuntime.GetUserDatabase(); await conn.InsertAsync(item); // stage the image... if (image != null) { // new path... var manager = new ReportImageCacheManager(); var folder = await manager.GetCacheFolderAsync(); // create... await image.CopyAsync(folder, item.NativeId + ".jpg"); } // return... return(item); }
private async Task StageImageAsync(IStorageFile image) { // new path... var manager = new ReportImageCacheManager(); var folder = await manager.GetCacheFolderAsync(); // save it as a file that's no longer than 640 pixels on its longest edge... var newImage = await folder.CreateFileAsync(this.NativeId + ".jpg", CreationCollisionOption.ReplaceExisting); await ImageHelper.ResizeAndSaveAsAsync(image, newImage, 640); }
internal async Task InitializeAsync(ReportImageCacheManager manager) { // get... var imageUrl = await manager.GetLocalImageUriAsync(this); if (!(string.IsNullOrEmpty(imageUrl))) { // set it up... this.ImageUri = imageUrl; } else { // enqueue an image... manager.EnqueueImageDownload(this); } }
private async Task ReloadReportsFromCacheAsync() { // setup a load operation to populate the collection from the cache... using (this.EnterBusy()) { var reports = await ReportItem.GetAllFromCacheAsync(); // update the model... this.Items.Clear(); foreach (ReportItem report in reports) { this.Items.Add(new ReportViewItem(report)); } // go through and initialize... var manager = new ReportImageCacheManager(); foreach (var item in this.Items) { await item.InitializeAsync(manager); } // update the badge... var badge = new BadgeNotificationBuilder(this.Items.Count); badge.Update(); // update the tile... string message = "1 report"; if (this.Items.Count != 1) { message = string.Format("{0} reports", this.Items.Count); } var tile = new TileNotificationBuilder(new string[] { "StreetFoo", message }, TileTemplateType.TileWide310x150PeekImage01); tile.ImageUris.Add("ms-appx:///Assets/Toast.jpg"); // update... tile.UpdateAndReplicate(TileTemplateType.TileSquare150x150PeekImageAndText02); } }
protected override async void ItemChanged() { base.ItemChanged(); // if we're not new, load the image... if (!(this.IsNew)) { var manager = new ReportImageCacheManager(); await this.Item.InitializeAsync(manager); // initialie the image... if (this.Item.HasImage) { var image = new BitmapImage(); image.UriSource = new Uri(this.Item.ImageUri); this.Image = image; } } // raise the new regardless... this.OnPropertyChanged("IsNew"); }
private async Task ReloadReportsFromCacheAsync() { // setup a load operation to populate the collection from the cache... using (this.EnterBusy()) { var reports = await ReportItem.GetAllFromCacheAsync(); // update the model... this.Items.Clear(); foreach (ReportItem report in reports) this.Items.Add(new ReportViewItem(report)); // go through and initialize... var manager = new ReportImageCacheManager(); foreach (var item in this.Items) await item.InitializeAsync(manager); // update the badge... var badge = new BadgeNotificationBuilder(this.Items.Count); badge.Update(); // update the tile... string message = "1 report"; if (this.Items.Count != 1) message = string.Format("{0} reports", this.Items.Count); var tile = new TileNotificationBuilder(new string[] { "StreetFoo", message }, TileTemplateType.TileWidePeekImage01); tile.ImageUris.Add("ms-appx:///Assets/Toast.jpg"); tile.UpdateAndReplicate(TileTemplateType.TileSquarePeekImageAndText02); } }
internal static async Task<ReportItem> CreateReportItemAsync(string title, string description, IMappablePoint point, IStorageFile image) { var item = new ReportItem() { Title = title, Description = description, NativeId = Guid.NewGuid().ToString(), Status = ReportItemStatus.New }; item.SetLocation(point); // save... var conn = StreetFooRuntime.GetUserDatabase(); await conn.InsertAsync(item); // stage the image... if (image != null) { // new path... var manager = new ReportImageCacheManager(); var folder = await manager.GetCacheFolderAsync(); // create... await image.CopyAsync(folder, item.NativeId + ".jpg"); } // return... return item; }
private async Task SearchAsync(string queryText) { // flag... this.SearchDone = true; // set... this.QueryText = queryText; // set the narrative... if (string.IsNullOrEmpty(queryText)) { this.QueryNarrative = string.Empty; } else { this.QueryNarrative = string.Format("Results for '{0}'", queryText); } // load... var reports = await ReportItem.SearchCacheAsync(queryText); this.MasterItems.Clear(); foreach (var report in reports) { this.MasterItems.Add(new ReportViewItem(report)); } // what was our selected filter? var current = this.ActiveFilter; if (current != null) { var builder = new ToastNotificationBuilder(current.Description); builder.Update(); } // do we have anything? this.Filters.Clear(); if (this.MasterItems.Any()) { // all filter... var allFilter = new SearchFilter("all", this.MasterItems.Count, null, false); allFilter.SelectionCommand = new DelegateCommand(async(args) => await HandleFilterActivatedAsync(allFilter)); this.Filters.Add(allFilter); // build up a list of nouns... var nouns = new Dictionary <string, int>(); var regex = new Regex(@"\b\w+$", RegexOptions.Singleline | RegexOptions.IgnoreCase); foreach (var report in reports) { var match = regex.Match(report.Title); // word... string noun = match.Value.ToLower(); if (!(nouns.ContainsKey(noun))) { nouns[noun] = 0; } nouns[noun]++; } // add the filters... foreach (var noun in nouns.Keys) { var filter = new SearchFilter(noun, nouns[noun], noun); filter.SelectionCommand = new DelegateCommand(async(args) => await HandleFilterActivatedAsync(filter)); this.Filters.Add(filter); } // update... var manager = new ReportImageCacheManager(); foreach (var report in this.MasterItems) { await report.InitializeAsync(manager); } } // do we need to select the filter? var lastQuery = await SettingItem.GetValueAsync(LastQueryKey); if (lastQuery == queryText) { // select the filter... var lastFilterName = await SettingItem.GetValueAsync(LastFilterKey); if (!(string.IsNullOrEmpty(lastFilterName))) { ActivateFilter(lastFilterName); } } else { // update... await SettingItem.SetValueAsync(LastQueryKey, queryText); } // apply the filter... this.ApplyFilter(); }
private async Task SearchAsync(string queryText) { // flag... this.SearchDone = true; // set... this.QueryText = queryText; // set the narrative... if (string.IsNullOrEmpty(queryText)) this.QueryNarrative = string.Empty; else this.QueryNarrative = string.Format("Results for '{0}'", queryText); // load... var reports = await ReportItem.SearchCacheAsync(queryText); this.MasterItems.Clear(); foreach (var report in reports) this.MasterItems.Add(new ReportViewItem(report)); // what was our selected filter? var current = this.ActiveFilter; if (current != null) { var builder = new ToastNotificationBuilder(current.Description); builder.Update(); } // do we have anything? this.Filters.Clear(); if (this.MasterItems.Any()) { // all filter... var allFilter = new SearchFilter("all", this.MasterItems.Count, null, false); allFilter.SelectionCommand = new DelegateCommand(async (args) => await HandleFilterActivatedAsync(allFilter)); this.Filters.Add(allFilter); // build up a list of nouns... var nouns = new Dictionary<string, int>(); var regex = new Regex(@"\b\w+$", RegexOptions.Singleline | RegexOptions.IgnoreCase); foreach (var report in reports) { var match = regex.Match(report.Title); // word... string noun = match.Value.ToLower(); if (!(nouns.ContainsKey(noun))) nouns[noun] = 0; nouns[noun]++; } // add the filters... foreach (var noun in nouns.Keys) { var filter = new SearchFilter(noun, nouns[noun], noun); filter.SelectionCommand = new DelegateCommand(async (args) => await HandleFilterActivatedAsync(filter)); this.Filters.Add(filter); } // update... var manager = new ReportImageCacheManager(); foreach (var report in this.MasterItems) await report.InitializeAsync(manager); } // do we need to select the filter? var lastQuery = await SettingItem.GetValueAsync(LastQueryKey); if (lastQuery == queryText) { // select the filter... var lastFilterName = await SettingItem.GetValueAsync(LastFilterKey); if (!(string.IsNullOrEmpty(lastFilterName))) ActivateFilter(lastFilterName); } else { // update... await SettingItem.SetValueAsync(LastQueryKey, queryText); } // apply the filter... this.ApplyFilter(); }
private async Task ReloadReportsFromCache() { // setup a load operation to populate the collection from the cache... using (this.EnterBusy()) { var reports = await ReportItem.GetAllFromCacheAsync(); // update the model... this.Items.Clear(); foreach (ReportItem report in reports) this.Items.Add(new ReportViewItem(report)); // go through and initialize... var manager = new ReportImageCacheManager(); foreach (var item in this.Items) await item.InitializeAsync(manager); } }