示例#1
0
        private void GetContacts(InvokeRequest request)
        {
            CrossContacts.Current.PreferContactAggregation = false;
            var contacts = CrossContacts.Current.Contacts.ToList();
            var table    = new Table();

            foreach (Contact contact in contacts)
            {
                var contactPhones = new JArray();
                var contactEmails = new JArray();

                foreach (Phone phone in contact.Phones)
                {
                    contactPhones.Add(phone.Number);
                }

                foreach (Email email in contact.Emails)
                {
                    contactEmails.Add(email.Address);
                }

                table.Add(new Row
                {
                    contact.DisplayName,
                    contactPhones,
                    contactEmails
                });
            }

            request.UpdateTable(table);
            request.Close();
        }
        private void CreateNotification(InvokeRequest request)
        {
            string title          = request.Parameters["title"].Value <string>();
            string message        = request.Parameters["message"].Value <string>();
            int    notificationID = _notificationID++;

            CrossLocalNotifications.Current.Show(title, message, notificationID);
            request.UpdateTable(new Table
            {
                new Row
                {
                    notificationID
                }
            });
            request.Close();
        }
示例#3
0
        private async void PickPicture(InvokeRequest request)
        {
            var result = await CrossMedia.Current.PickPhotoAsync();

            if (result == null)
            {
                await request.UpdateTable(new Table
                {
                    new JArray
                    {
                        result.GetStream().ReadAllBytes()
                    }
                });
            }

            await request.Close();
        }
        public async void Test(InvokeRequest request)
        {
            //request.Mode = Table.Mode.Append;
            for (int i = 0; i < 999; i++)
            {
                await request.UpdateTable(new Table
                {
                    new Row
                    {
                        true,
                        "test" + i,
                    }
                });

                await Task.Delay(1000);
            }
            await request.Close();
        }
 private async void ScanWiFiNetworks(InvokeRequest request)
 {
     _deviceSettings.ScanWiFiPoints((List <WiFiAccessPoint> accessPoints) =>
     {
         Table table = new Table();
         foreach (WiFiAccessPoint accessPoint in accessPoints)
         {
             table.Add(new Row
             {
                 accessPoint.Ssid,
                 accessPoint.Bssid,
                 accessPoint.SignalLevel,
                 accessPoint.Frequency
             });
         }
         request.UpdateTable(table);
         request.Close();
     });
 }
        private async void ScanCode(InvokeRequest request)
        {
            var result = await _scanner.Scan();

            if (result != null)
            {
                await request.UpdateTable(new Table
                {
                    new Row
                    {
                        result.Text,
                        result.BarcodeFormat.ToString(),
                        result.Timestamp
                    }
                });
            }

            await request.Close();
        }
示例#7
0
        private async void TakePicture(InvokeRequest request)
        {
            var result = await CrossMedia.Current.TakePhotoAsync(
                new StoreCameraMediaOptions
            {
                Name      = "DSAPicture.jpg",
                Directory = "Pictures"
            }
                );

            if (result != null)
            {
                await request.UpdateTable(new Table
                {
                    new Row
                    {
                        result.GetStream().ReadAllBytes()
                    }
                });
            }

            await request.Close();
        }