예제 #1
0
 async Task CompleteItem(TodoItem item)
 {
     item.Done = true;
     await manager.SaveTaskAsync(item);
     todoList.ItemsSource = await manager.GetTodoItemsAsync();
 }
예제 #2
0
        /// <summary>
        /// Click method for Add Button. 
        /// </summary>
        /// <returns>The add.</returns>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        public async void OnAdd(object sender, EventArgs e)
        {
            str = newItemName.Text;
            

            if (string.IsNullOrWhiteSpace(str))
            {
                var scanPage = new ZXingScannerPage()
                {
                    Title = "ScanPage",
                    DefaultOverlayTopText = "Scan a ISBN barcode.",
                    DefaultOverlayBottomText = "",
                };
                // スキャナページを表示
                await Navigation.PushModalAsync(scanPage);

                // データが取れると発火
                scanPage.OnScanResult += (result) =>
                {
                    // スキャン停止
                    scanPage.IsScanning = false;
                    System.Diagnostics.Debug.WriteLine("Scanned");

                    Device.BeginInvokeOnMainThread(async () =>
                    {
                        await Navigation.PopModalAsync();

                        str = result.Text;

                        itemInfo = await itemLookup.Lookup(str);
                        System.Diagnostics.Debug.WriteLine("Lookuped");

                        if (itemInfo != null)
                        {
                            if (await DisplayAlert("Add", $"Add {itemInfo.Name} to azure?", "Yes", "No"))
                                await AddItem(itemInfo);
                        }
                        else
                            await DisplayAlert("Error", "Invalid Number", "OK");



                        newItemName.Text = string.Empty;
                        newItemName.Unfocus();

                    });
                };
            }
            else 
            {
                itemInfo = await itemLookup.Lookup(str);

                if (itemInfo != null)
                {
                    if (await DisplayAlert("Add", $"Add {itemInfo.Name} to azure?", "Yes", "No"))
                    {
                        await AddItem(itemInfo);
                    }
                }
                else
                    await DisplayAlert("Error", "Invalid Number", "OK");

            }

        }
예제 #3
0
 // Data methods
 async Task AddItem(TodoItem item)
 {
     await manager.SaveTaskAsync(item);
     todoList.ItemsSource = await manager.GetTodoItemsAsync();
 }