Esempio n. 1
0
        public void DoVolumeChanges(int delta)
        {
            try
            {
                Invoke((MethodInvoker) delegate
                {
                    int CurrentVolume = (int)Math.Round(VolumeHandler.GetMasterVolume());
                    if (CursorInTaskbar() && !IsTaskbarHidden())
                    {
                        inputHandler.TimeOutHelper = 10;
                        if (delta < 0)
                        {
                            if (inputHandler.IsAltDown)
                            {
                                VolumeHandler.SetMasterVolume(CurrentVolume - 1);
                            }
                            else if (CurrentVolume <= Properties.Settings.Default.PreciseScrollThreshold)
                            {
                                VolumeHandler.SetMasterVolume(CurrentVolume - 1);
                            }
                            else
                            {
                                VolumeHandler.SetMasterVolume(CurrentVolume - Properties.Settings.Default.VolumeStep);
                            }
                        }
                        else
                        {
                            if (inputHandler.IsAltDown)
                            {
                                VolumeHandler.SetMasterVolume(CurrentVolume + 1);
                            }
                            else if (CurrentVolume < Properties.Settings.Default.PreciseScrollThreshold)
                            {
                                VolumeHandler.SetMasterVolume(CurrentVolume + 1);
                            }
                            else
                            {
                                VolumeHandler.SetMasterVolume(CurrentVolume + Properties.Settings.Default.VolumeStep);
                            }
                        }

                        CurrentVolume      = (int)Math.Round(VolumeHandler.GetMasterVolume());
                        lblVolumeText.Text = CurrentVolume + "%";
                        trayIcon.Text      = "TbVolScroll - " + CurrentVolume + "%";


                        Point CursorPosition = Cursor.Position;
                        Width   = CurrentVolume + Properties.Settings.Default.BarWidth;
                        Left    = CursorPosition.X - Width / 2;
                        Top     = CursorPosition.Y - Height - 5;
                        Opacity = Properties.Settings.Default.BarOpacity;
                        if (Properties.Settings.Default.UseBarGradient)
                        {
                            lblVolumeText.BackColor = CalculateColor(CurrentVolume);
                        }
                        else
                        {
                            lblVolumeText.BackColor = Properties.Settings.Default.BarColor;
                        }
                        if (!IsDisplayingVolume)
                        {
                            IsDisplayingVolume = true;
                            Application.DoEvents();
                            AutoHideVolume();
                        }
                    }
                    else
                    {
                        Invoke((MethodInvoker) delegate
                        {
                            Hide();
                        });
                        IsDisplayingVolume = false;
                    }
                });
            }
            catch { }
        }
Esempio n. 2
0
 private void ResetVolume(object sender, EventArgs e)
 {
     VolumeHandler.SetMasterVolume(0);
 }