private void MakePhoneCall(InvokeRequest request)
        {
            var to = request.Parameters["To"].Value <string>();

            CrossMessaging.Current.PhoneDialer.MakePhoneCall(to);
            request.Close();
        }
        private void CancelNotification(InvokeRequest request)
        {
            int nid = request.Parameters["notificationId"].Value <int>();

            CrossLocalNotifications.Current.Cancel((int)nid);
            request.Close();
        }
예제 #3
0
        public async void Drive(InvokeRequest request)
        {
            var directionToken = request.Parameters["direction"];
            var leftRightToken = request.Parameters["leftRight"];

            if (directionToken.Type == JTokenType.String &&
                leftRightToken.Type == JTokenType.Float)
            {
                string           direction       = directionToken.Value <string>();
                float            leftRight       = leftRightToken.Value <float>();
                DRDriveDirection?actualDirection = null;
                switch (direction)
                {
                case "forward":
                    actualDirection = DRDriveDirection.Forward;
                    break;

                case "backward":
                    actualDirection = DRDriveDirection.Backward;
                    break;

                case "stop":
                    actualDirection = DRDriveDirection.Stop;
                    break;
                }
                if (actualDirection.HasValue)
                {
                    _robot.Drive(actualDirection.Value, leftRight);
                }
            }
            await request.Close();
        }
예제 #4
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();
        }
예제 #5
0
        private async void SetClipboardContents(InvokeRequest request)
        {
            await request.Close();

            var text = request.Parameters["text"].Value <string>();

            await CrossShare.Current.SetClipboardText(text);
        }
        private void SendSMS(InvokeRequest request)
        {
            var to      = request.Parameters["to"].Value <string>();
            var message = request.Parameters["message"].Value <string>();

            CrossMessaging.Current.SmsMessenger.SendSms(to, message);
            request.Close();
        }
        public void NavigateToCoord(InvokeRequest request)
        {
            string name      = request.Parameters["Name"].Value <string>();
            double longitude = request.Parameters["Longitude"].Value <double>();
            double latitude  = request.Parameters["Latitude"].Value <double>();

            CrossExternalMaps.Current.NavigateTo(name, latitude, longitude);
            request.Close();
        }
        private void SendEmail(InvokeRequest request)
        {
            var to      = request.Parameters["To"].Value <string>();
            var subject = request.Parameters["Subject"].Value <string>();
            var message = request.Parameters["Message"].Value <string>();

            CrossMessaging.Current.EmailMessenger.SendEmail(to, subject, message);
            request.Close();
        }
예제 #9
0
        private async void Share(InvokeRequest request)
        {
            await request.Close();

            var title = request.Parameters["title"].Value <string>();
            var text  = request.Parameters["text"].Value <string>();

            await CrossShare.Current.Share(text, title);
        }
예제 #10
0
        private async void ShareLink(InvokeRequest request)
        {
            await request.Close();

            var url     = request.Parameters["url"].Value <string>();
            var message = request.Parameters["msg"].Value <string>();
            var title   = request.Parameters["title"].Value <string>();

            await CrossShare.Current.ShareLink(url, message, title);
        }
예제 #11
0
        public async void TurnByDegrees(InvokeRequest request)
        {
            var degreeToken = request.Parameters["degrees"];

            if (degreeToken.Type == JTokenType.Float)
            {
                _robot.TurnByDegrees(degreeToken.Value <float>());
            }
            await request.Close();
        }
예제 #12
0
        private void Vibrate(InvokeRequest request)
        {
            JToken token = request.Parameters["duration"];

            if (token != null && token.Type == JTokenType.Integer)
            {
                CrossVibrate.Current.Vibration(token.Value <int>());
            }
            else
            {
                CrossVibrate.Current.Vibration();
            }
            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();
        }
예제 #14
0
        public async void SetParkState(InvokeRequest request)
        {
            JToken stateToken = request.Parameters["state"];

            if (stateToken.Type == JTokenType.Boolean)
            {
                if (stateToken.Value <bool>())
                {
                    _robot.DeployKickstands();
                }
                else
                {
                    _robot.RetractKickstands();
                }
            }
            await request.Close();
        }
예제 #15
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();
        }
예제 #16
0
        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();
        }
예제 #17
0
        private async void _createRngAction(InvokeRequest request)
        {
            var rngName = request.Parameters["rngName"].Value <string>();

            if (string.IsNullOrEmpty(rngName))
            {
                return;
            }
            if (Responder.SuperRoot.Children.ContainsKey(rngName))
            {
                return;
            }

            var newRng = Responder.SuperRoot.CreateChild(rngName, "rng").BuildNode();

            await request.Close();

            await SaveNodes();
        }
 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();
     });
 }
예제 #19
0
        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();
        }
예제 #20
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();
        }
예제 #21
0
        private async void OpenInBrowser(InvokeRequest request)
        {
            // We should just close the request now.
            await request.Close();

            var url     = request.Parameters["url"].Value <string>();
            var options = new BrowserOptions();

            var showTitle  = request.Parameters["showTitle"];
            var readerMode = request.Parameters["readerMode"];

            if (PlatformHelper.Android && showTitle != null && showTitle.Type == JTokenType.Boolean)
            {
                options.ChromeShowTitle = showTitle.Value <bool>();
            }

            if (PlatformHelper.iOS && readerMode != null && readerMode.Type == JTokenType.String)
            {
                options.UseSafairReaderMode = readerMode.Value <bool>();
            }

            await CrossShare.Current.OpenBrowser(url, options);
        }
예제 #22
0
 public async void Stop(InvokeRequest request)
 {
     _robot.Drive(DRDriveDirection.Stop, 0.0f);
     await request.Close();
 }
예제 #23
0
 public async void PoleUp(InvokeRequest request)
 {
     _robot.PoleUp();
     await request.Close();
 }