コード例 #1
0
        private void Menu_AddItem(ContextMenu c, String header, TouchOption.Universal option, Devices side)
        {
            MenuItem m = new MenuItem();

            m.Header = header;
            m.Click += delegate
            {
                _lastPressedMenu = side;

                if (side == Devices.L && option == TouchOption.Universal.OtherL)
                {
                    _mainWindow.GoToPage(MainWindow.Pages.TouchCustomAction);
                }
                else if (side == Devices.R && option == TouchOption.Universal.OtherR)
                {
                    _mainWindow.GoToPage(MainWindow.Pages.TouchCustomAction);
                }
                else
                {
                    if (side == Devices.L)
                    {
                        _lastLeftOption       = option;
                        LeftOption.TextDetail = m.Header.ToString();
                    }
                    else
                    {
                        _lastRightOption       = option;
                        RightOption.TextDetail = m.Header.ToString();
                    }
                    BluetoothService.Instance.SendAsync(SPPMessageBuilder.Touch.SetOptions(_lastLeftOption, _lastRightOption));
                }
            };
            m.Style = (Style)FindResource("MenuItemStyle");
            c.Items.Add(m);
        }
コード例 #2
0
        private void CustomActionPageOnAccept(object sender, CustomAction e)
        {
            if (e == null)
            {
                return;
            }

            if (_lastPressedMenu == Devices.L)
            {
                _lastLeftOption                            = TouchOption.Universal.OtherL;
                LeftOption.TextDetail                      = $"{Loc.GetString("touchoption_custom_prefix")} {e}";
                Settings.Default.LeftCustomAction          = (int)e.Action;
                Settings.Default.LeftCustomActionParameter = e.Parameter;
                BluetoothService.Instance.SendAsync(SPPMessageBuilder.Touch.SetOptions(TouchOption.Universal.OtherL, _lastRightOption));
            }
            else
            {
                _lastRightOption                            = TouchOption.Universal.OtherR;
                RightOption.TextDetail                      = $"{Loc.GetString("touchoption_custom_prefix")} {e}";
                Settings.Default.RightCustomAction          = (int)e.Action;
                Settings.Default.RightCustomActionParameter = e.Parameter;
                BluetoothService.Instance.SendAsync(SPPMessageBuilder.Touch.SetOptions(_lastLeftOption, TouchOption.Universal.OtherR));
            }

            Settings.Default.MinimizeTray = true;
            AutoStartHelper.Enabled       = true;
            Settings.Default.Save();
        }
コード例 #3
0
        private String OptionToString(TouchOption.Universal b, Devices d)
        {
            switch (b)
            {
            case TouchOption.Universal.VoiceAssistant:
                return("Voice Assistant (Android only)");

            case TouchOption.Universal.QuickAmbientSound:
                return("Quick Ambient Sound");

            case TouchOption.Universal.Volume:
                return(d == Devices.L ? "Volume Down" : "Volume Up");

            case TouchOption.Universal.AmbientSound:
                return("Ambient Sound");

            case TouchOption.Universal.SpotifySpotOn:
                return("Spotify SpotOn (Android only)");

            case TouchOption.Universal.OtherL:
                var currentCustomActionL = (Settings.Default.LeftCustomAction == -1) ? (CustomAction)null :
                                           new CustomAction((CustomAction.Actions)Settings.Default.LeftCustomAction, Settings.Default.LeftCustomActionParameter);
                return("Custom Action: " + (currentCustomActionL == null ? "Not set" : currentCustomActionL.ToString()));

            case TouchOption.Universal.OtherR:
                var currentCustomActionR = (Settings.Default.RightCustomAction == -1) ? (CustomAction)null :
                                           new CustomAction((CustomAction.Actions)Settings.Default.RightCustomAction, Settings.Default.RightCustomActionParameter);
                return("Custom Action: " + (currentCustomActionR == null ? "Not set" : currentCustomActionR.ToString()));
            }

            return("Unknown");
        }
コード例 #4
0
        private String OptionToString(TouchOption.Universal b, Devices d)
        {
            switch (b)
            {
            case TouchOption.Universal.VoiceAssistant:
                return(Loc.GetString("touchoption_voice"));

            case TouchOption.Universal.QuickAmbientSound:
                return(Loc.GetString("touchoption_quickambientsound"));

            case TouchOption.Universal.Volume:
                return(d == Devices.L ?
                       Loc.GetString("touchoption_volume_down") :
                       Loc.GetString("touchoption_volume_up"));

            case TouchOption.Universal.AmbientSound:
                return(Loc.GetString("touchoption_ambientsound"));

            case TouchOption.Universal.SpotifySpotOn:
                return(Loc.GetString("touchoption_spotify"));

            case TouchOption.Universal.OtherL:
                var currentCustomActionL = (Settings.Default.LeftCustomAction == -1) ? (CustomAction)null :
                                           new CustomAction((CustomAction.Actions)Settings.Default.LeftCustomAction, Settings.Default.LeftCustomActionParameter);
                return(Loc.GetString("touchoption_custom_prefix") + " " + (currentCustomActionL == null ? Loc.GetString("touchoption_custom_null") : currentCustomActionL.ToString()));

            case TouchOption.Universal.OtherR:
                var currentCustomActionR = (Settings.Default.RightCustomAction == -1) ? (CustomAction)null :
                                           new CustomAction((CustomAction.Actions)Settings.Default.RightCustomAction, Settings.Default.RightCustomActionParameter);
                return(Loc.GetString("touchoption_custom_prefix") + " " + (currentCustomActionR == null ? Loc.GetString("touchoption_custom_null") : currentCustomActionR.ToString()));
            }

            return(Loc.GetString("touchoption_custom_unknown"));
        }
コード例 #5
0
 public static SPPMessage SetOptions(TouchOption.Universal left, TouchOption.Universal right)
 {
     byte[] payload = new byte[2];
     payload[0] = TouchOption.ToRawByte(left);
     payload[1] = TouchOption.ToRawByte(right);
     return(new SPPMessage(SPPMessage.MessageIds.MSG_ID_SET_TOUCHPAD_OPTION,
                           SPPMessage.MsgType.Request, payload));
 }
コード例 #6
0
        public override void ParseMessage(SPPMessage msg)
        {
            if (msg.Id != HandledType)
            {
                return;
            }

            OptionType = TouchOption.ToUniversal(msg.Payload[0]);
        }
コード例 #7
0
        private void Menu_AddItem(ContextMenu c, String header, TouchOption.Universal option, Devices side)
        {
            MenuItem m = new MenuItem();

            m.Header = header;
            m.Click += delegate
            {
                _lastPressedMenu = side;

                if (side == Devices.L && option == TouchOption.Universal.OtherL)
                {
                    int act = Settings.Default.LeftCustomAction;
                    _mainWindow.CustomActionPage.CurrentSide = Devices.L;

                    _mainWindow.CustomActionPage.Action.TextDetail = act < 0 ? Loc.GetString("touchoption_custom_null") :
                                                                     new CustomAction((CustomAction.Actions)act,
                                                                                      Settings.Default.LeftCustomActionParameter).ToLongString();
                    _mainWindow.GoToPage(MainWindow.Pages.TouchCustomAction);
                }
                else if (side == Devices.R && option == TouchOption.Universal.OtherR)
                {
                    int act = Settings.Default.RightCustomAction;
                    _mainWindow.CustomActionPage.CurrentSide = Devices.R;

                    _mainWindow.CustomActionPage.Action.TextDetail = act < 0 ? Loc.GetString("touchoption_custom_null") :
                                                                     new CustomAction((CustomAction.Actions)act,
                                                                                      Settings.Default.RightCustomActionParameter).ToLongString();
                    _mainWindow.GoToPage(MainWindow.Pages.TouchCustomAction);
                }
                else
                {
                    if (side == Devices.L)
                    {
                        _lastLeftOption       = option;
                        LeftOption.TextDetail = m.Header.ToString();

                        Settings.Default.LeftCustomAction          = -1;
                        Settings.Default.LeftCustomActionParameter = "";
                        Settings.Default.Save();
                    }
                    else
                    {
                        _lastRightOption       = option;
                        RightOption.TextDetail = m.Header.ToString();

                        Settings.Default.RightCustomAction          = -1;
                        Settings.Default.RightCustomActionParameter = "";
                        Settings.Default.Save();
                    }
                    BluetoothService.Instance.SendAsync(SPPMessageBuilder.Touch.SetOptions(_lastLeftOption, _lastRightOption));
                }
            };
            m.Style = (Style)FindResource("MenuItemStyle");
            c.Items.Add(m);
        }
コード例 #8
0
        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;
            }
        }
コード例 #9
0
        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.EnableEqualizer:
                Dispatcher.Invoke(() =>
                {
                    EQToggle.Toggle();
                    UpdateEqualizer();
                });
                break;

            case CustomAction.Actions.SwitchEqualizerPreset:
                Dispatcher.Invoke(() =>
                {
                    var newVal = PresetSlider.Value + 1;
                    if (newVal >= 5)
                    {
                        newVal = 0;
                    }

                    PresetSlider.Value = newVal;
                    EQToggle.SetChecked(true);
                    UpdateEqualizer();
                });
                break;
            }
        }
コード例 #10
0
        private void InstanceOnExtendedStatusUpdate(object sender, ExtendedStatusUpdateParser e)
        {
            Dispatcher.Invoke(() =>
            {
                LockToggle.SetChecked(e.TouchpadLock);

                _lastLeftOption  = e.TouchpadOptionL;
                _lastRightOption = e.TouchpadOptionR;

                LeftOption.TextDetail  = OptionToString(e.TouchpadOptionL, Devices.L);
                RightOption.TextDetail = OptionToString(e.TouchpadOptionR, Devices.R);
                DoubleTapVolume.Switch.SetChecked(e.OutsideDoubleTap);
            });
        }
コード例 #11
0
 private void InstanceOnOtherOption(object sender, TouchOption.Universal e)
 {
     if (e == TouchOption.Universal.OtherL)
     {
         if (Settings.Default.LeftCustomAction == -1)
         {
             return;
         }
         PerformCustomAction((CustomAction.Actions)Settings.Default.LeftCustomAction,
                             Settings.Default.LeftCustomActionParameter);
     }
     else if (e == TouchOption.Universal.OtherR)
     {
         if (Settings.Default.RightCustomAction == -1)
         {
             return;
         }
         PerformCustomAction((CustomAction.Actions)Settings.Default.RightCustomAction,
                             Settings.Default.RightCustomActionParameter);
     }
 }