private void InstanceOnAmbientEnabledUpdateResponse(object sender, bool e)
 {
     Dispatcher.Invoke(() =>
     {
         AmbientToggle.SetChecked(e);
     });
 }
 private void InstanceOnExtendedStatusUpdate(object sender, ExtendedStatusUpdateParser e)
 {
     Dispatcher.Invoke(() =>
     {
         AmbientToggle.SetChecked(e.AmbientSoundEnabled);
         VoiceFocusToggle.SetChecked(e.AmbientSoundMode == Constants.AmbientType.VoiceFocus);
         AmbientVolume.Value = e.AmbientSoundVolume;
     });
 }
        private void InstanceOnOtherOption(object sender, TouchOption.Universal e)
        {
            int action;

            if (e == TouchOption.Universal.OtherL)
            {
                if (Settings.Default.LeftCustomAction == -1)
                {
                    return;
                }
                action = Settings.Default.LeftCustomAction;
            }
            else if (e == TouchOption.Universal.OtherR)
            {
                if (Settings.Default.RightCustomAction == -1)
                {
                    return;
                }
                action = Settings.Default.RightCustomAction;
            }
            else
            {
                return;
            }

            switch ((CustomAction.Actions)action)
            {
            case CustomAction.Actions.AmbientVolumeUp:
                Dispatcher.Invoke(() =>
                {
                    AmbientToggle.SetChecked(true);
                    BluetoothService.Instance.SendAsync(SPPMessageBuilder.Ambient.SetEnabled(AmbientToggle.IsChecked));

                    AmbientVolume.Value++;
                    BluetoothService.Instance.SendAsync(
                        SPPMessageBuilder.Ambient.SetVolume((int)AmbientVolume.Value));
                });
                break;

            case CustomAction.Actions.AmbientVolumeDown:
                Dispatcher.Invoke(() =>
                {
                    AmbientToggle.SetChecked(true);
                    BluetoothService.Instance.SendAsync(SPPMessageBuilder.Ambient.SetEnabled(AmbientToggle.IsChecked));

                    AmbientVolume.Value--;
                    BluetoothService.Instance.SendAsync(
                        SPPMessageBuilder.Ambient.SetVolume((int)AmbientVolume.Value));
                });
                break;
            }
        }
        private void InstanceOnExtendedStatusUpdate(object sender, ExtendedStatusUpdateParser e)
        {
            Dispatcher.Invoke(() =>
            {
                AmbientToggle.SetChecked(e.AmbientSoundEnabled);
                AmbientVolume.Value = e.AmbientSoundVolume;

                if (BluetoothService.Instance.ActiveModel == Model.BudsPlus)
                {
                    ExtraLoud.Switch.SetChecked(e.ExtraHighAmbientEnabled);
                    AmbientVolume.Maximum = e.ExtraHighAmbientEnabled ? 3 : 2;
                }
                else if (BluetoothService.Instance.ActiveModel == Model.Buds)
                {
                    VoiceFocusToggle.SetChecked(e.AmbientSoundMode == AmbientType.VoiceFocus);
                }
            });
        }