/*
         * Tray
         */
        private void GenerateTrayContext(int?bl = null, int?br = null, int?bcase = null)
        {
            if (bl != null)
            {
                _previousTrayBL = (int)bl;
            }
            if (br != null)
            {
                _previousTrayBR = (int)br;
            }
            if (bcase != null)
            {
                _previousTrayBC = (int)bcase;
            }

            Dispatcher.Invoke(() =>
            {
                ContextMenu ctxMenu = new ContextMenu();
                ctxMenu.Style       = (Style)FindResource("SmallContextMenuStyle");

                int staticCount = 0;

                if (_previousTrayBL > 0)
                {
                    MenuItem left  = new MenuItem();
                    left.Header    = $"{Loc.GetString("left")}: {_previousTrayBL}%";
                    left.IsEnabled = false;
                    left.Style     = (Style)FindResource("SmallMenuItemStyle-Static");
                    ctxMenu.Items.Add(left);
                    staticCount++;
                }
                if (_previousTrayBR > 0)
                {
                    MenuItem right  = new MenuItem();
                    right.Header    = $"{Loc.GetString("right")}: {_previousTrayBR}%";
                    right.IsEnabled = false;
                    right.Style     = (Style)FindResource("SmallMenuItemStyle-Static");
                    ctxMenu.Items.Add(right);
                    staticCount++;
                }
                if (_previousTrayBC > 0)
                {
                    MenuItem c  = new MenuItem();
                    c.Header    = $"{Loc.GetString("case")}: {_previousTrayBC}%";
                    c.IsEnabled = false;
                    c.Style     = (Style)FindResource("SmallMenuItemStyle-Static");
                    ctxMenu.Items.Add(c);
                    staticCount++;
                }

                if (staticCount > 0)
                {
                    Menu_AddSeparator(ctxMenu);
                    MenuItem touchlockToggle = new MenuItem();
                    touchlockToggle.Header   = _touchpadPage.LockToggle.IsChecked ? Loc.GetString("tray_unlock_touchpad") : Loc.GetString("tray_lock_touchpad");
                    touchlockToggle.Click   += delegate
                    {
                        _touchpadPage.ToggleTouchlock();
                    };
                    touchlockToggle.Style = (Style)FindResource("SmallMenuItemStyle");
                    ctxMenu.Items.Add(touchlockToggle);

                    MenuItem equalizerToggle = new MenuItem();
                    equalizerToggle.Header   = _equalizerPage.EQToggle.IsChecked ? Loc.GetString("tray_disable_eq") : Loc.GetString("tray_enable_eq");
                    equalizerToggle.Click   += delegate
                    {
                        _equalizerPage.ToggleEqualizer();
                    };
                    equalizerToggle.Style = (Style)FindResource("SmallMenuItemStyle");
                    ctxMenu.Items.Add(equalizerToggle);

                    if (BluetoothService.Instance.ActiveModel != Model.BudsLive)
                    {
                        MenuItem ambientToggle = new MenuItem();
                        ambientToggle.Header   = _ambientSoundPage.AmbientToggle.IsChecked ? Loc.GetString("tray_disable_ambient_sound") : Loc.GetString("tray_enable_ambient_sound");
                        ambientToggle.Click   += delegate
                        {
                            _ambientSoundPage.ToggleAmbient();
                        };
                        ambientToggle.Style = (Style)FindResource("SmallMenuItemStyle");
                        ctxMenu.Items.Add(ambientToggle);
                    }

                    Menu_AddSeparator(ctxMenu);
                }

                MenuItem quit = new MenuItem();
                quit.Header   = Loc.GetString("tray_quit");
                quit.Click   += delegate
                {
                    var prev = Settings.Default.MinimizeTray;
                    Settings.Default.MinimizeTray = false;
                    this.Close();
                    Settings.Default.MinimizeTray = prev;
                };
                quit.Style = (Style)FindResource("SmallMenuItemStyle");
                ctxMenu.Items.Add(quit);

                _tbi.ContextMenu = ctxMenu;
            });
        }
Beispiel #2
0
        /*
         * Tray
         */
        private void GenerateTrayContext(int?bl = null, int?br = null, int?bcase = null)
        {
            if (bl != null)
            {
                _previousTrayBL = (int)bl;
            }
            if (br != null)
            {
                _previousTrayBR = (int)br;
            }
            if (bcase != null)
            {
                _previousTrayBC = (int)bcase;
            }

            Dispatcher.Invoke(() =>
            {
                ContextMenu ctxMenu = new ContextMenu();
                ctxMenu.Style       = (Style)FindResource("SmallContextMenuStyle");

                int staticCount = 0;

                if (_previousTrayBL > 0)
                {
                    MenuItem left  = new MenuItem();
                    left.Header    = $"Left: {_previousTrayBL}%";
                    left.IsEnabled = false;
                    left.Style     = (Style)FindResource("SmallMenuItemStyle-Static");
                    ctxMenu.Items.Add(left);
                    staticCount++;
                }
                if (_previousTrayBR > 0)
                {
                    MenuItem right  = new MenuItem();
                    right.Header    = $"Right: {_previousTrayBR}%";
                    right.IsEnabled = false;
                    right.Style     = (Style)FindResource("SmallMenuItemStyle-Static");
                    ctxMenu.Items.Add(right);
                    staticCount++;
                }
                if (_previousTrayBC > 0)
                {
                    MenuItem c  = new MenuItem();
                    c.Header    = $"Case: {_previousTrayBC}%";
                    c.IsEnabled = false;
                    c.Style     = (Style)FindResource("SmallMenuItemStyle-Static");
                    ctxMenu.Items.Add(c);
                    staticCount++;
                }

                if (staticCount > 0)
                {
                    Menu_AddSeparator(ctxMenu);
                    MenuItem touchlockToggle = new MenuItem();
                    touchlockToggle.Header   = _touchpadPage.LockToggle.IsChecked ? "Unlock Touchpad" : "Lock Touchpad";
                    touchlockToggle.Click   += delegate
                    {
                        _touchpadPage.ToggleTouchlock();
                    };
                    touchlockToggle.Style = (Style)FindResource("SmallMenuItemStyle");
                    ctxMenu.Items.Add(touchlockToggle);

                    MenuItem equalizerToggle = new MenuItem();
                    equalizerToggle.Header   = _equalizerPage.EQToggle.IsChecked ? "Disable Equalizer" : "Enable Equalizer";
                    equalizerToggle.Click   += delegate
                    {
                        _equalizerPage.ToggleEqualizer();
                    };
                    equalizerToggle.Style = (Style)FindResource("SmallMenuItemStyle");
                    ctxMenu.Items.Add(equalizerToggle);

                    MenuItem ambientToggle = new MenuItem();
                    ambientToggle.Header   = _ambientSoundPage.AmbientToggle.IsChecked ? "Disable Ambient Sound" : "Enable Ambient Sound";
                    ambientToggle.Click   += delegate
                    {
                        _ambientSoundPage.ToggleAmbient();
                    };
                    ambientToggle.Style = (Style)FindResource("SmallMenuItemStyle");
                    ctxMenu.Items.Add(ambientToggle);

                    Menu_AddSeparator(ctxMenu);
                }

                MenuItem quit = new MenuItem();
                quit.Header   = "Quit";
                quit.Click   += delegate
                {
                    var prev = Settings.Default.MinimizeTray;
                    Settings.Default.MinimizeTray = false;
                    this.Close();
                    Settings.Default.MinimizeTray = prev;
                };
                quit.Style = (Style)FindResource("SmallMenuItemStyle");
                ctxMenu.Items.Add(quit);

                _tbi.ContextMenu = ctxMenu;
            });
        }