Esempio n. 1
0
        private void OnExit(object sender, EventArgs e)
        {
            string msg = "Are you sure you want to exit?";

            if ((SmartVolManagerPackage.BgMusicManager.MusicState == SmartVolManagerPackage.BgMusicState.Play) || (SmartVolManagerPackage.BgMusicManager.AutoMuted == true))
            {
                msg = msg + " " + "Your music will be stopped.";
            }

            MessageBoxEx msgBoxEx = new MessageBoxEx(msg, UiCommands.mPlayerForm.WindowState == FormWindowState.Minimized ? "" : "Minimize");

            msgBoxEx.ShowDialog();
            switch (msgBoxEx.ButtonPressedIndex)
            {
            case 0:
                UiCommands.Exit();
                break;

            case 1:
                break;

            case 2:
                if (UiCommands.mPlayerForm != null)
                {
                    UiCommands.mPlayerForm.WindowState = FormWindowState.Minimized;
                }
                break;
            }
        }
Esempio n. 2
0
 private void PlayerForm_SizeChanged(object sender, EventArgs e)
 {
     if (WindowState == FormWindowState.Minimized)
     {
         UiCommands.HideMixer();
     }
 }
Esempio n. 3
0
 private void numericUpDown1_ValueChanged(object sender, EventArgs e)
 {
     if (!_ignoreEvent)
     {
         UiCommands.OnOperation(SmartVolManagerPackage.BgMusicManager.ActiveBgMusic.Id, Operation.SetVolumeToNoFade, (mVolumeUpDown.Value / 100.0m).ToString(), false, true);
     }
 }
Esempio n. 4
0
        private void mChangeBgMusicButton_Click(object sender, EventArgs e)
        {
            MusicConfigForm form = new MusicConfigForm();

            form.ShowDialog();
            UiCommands.UpdateUiForState();
        }
Esempio n. 5
0
        private void hotkeysToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UiCommands.UnregisterHotkeys();
            HotkeysForm form = new HotkeysForm();

            form.ShowDialog();
            UiCommands.RegisterHotkeys();
        }
Esempio n. 6
0
        public void Exit(bool showPrompt)
        {
            string msg = "Are you sure you want to exit?";

            if (showPrompt)
            {
                if ((SmartVolManagerPackage.BgMusicManager.MusicState == SmartVolManagerPackage.BgMusicState.Play) || (SmartVolManagerPackage.BgMusicManager.AutoMuted == true))
                {
                    msg = msg + " " + "Your music will be stopped.";
                }

                MessageBoxEx msgBoxEx = new MessageBoxEx(msg, "Minimize to Tray");
                msgBoxEx.ShowDialog();
                switch (msgBoxEx.ButtonPressedIndex)
                {
                case 0:
                    if (_isStandAlone)
                    {
                        Application.Exit();
                    }
                    else
                    {
                        UiCommands.Exit();
                    }
                    break;

                case 1:
                    break;

                case 2:
                    UiCommands.HideMixer();
                    break;
                }
            }
            else
            {
                if (_isStandAlone)
                {
                    Application.Exit();
                }
                else
                {
                    UiCommands.Exit();
                }
            }
        }
Esempio n. 7
0
        private bool chooseSelected()
        {
            try
            {
                if (mSoundTree.SelectedNode == null)
                {
                    return(false);
                }

                Cursor.Current = Cursors.WaitCursor;
                if ((mSoundTree.SelectedNode.Parent != null) && (mSoundTree.SelectedNode.Parent.Text == "Recent Sounds"))
                {
                    SoundPlayerInfo soundInfo = getRecentByName((string)mSoundTree.SelectedNode.Tag);
                    if (soundInfo.Name == "System Sounds")
                    {
                        MessageBox.Show("You cannot set this sound as your background music.");
                        Cursor.Current = Cursors.Default;
                        return(false);
                    }
                    soundInfo = makeSelectedAFavorite();
                    UiCommands.OnOperation(soundInfo.Id, Operation.ChangeMusic, "", false, true);
                    UpdateBgMusicUI();
                    refresh();
                }
                else if ((mSoundTree.SelectedNode.Parent != null) && (mSoundTree.SelectedNode.Parent.Text == "Favorites"))
                {
                    long            musicId   = long.Parse((string)mSoundTree.SelectedNode.Tag);
                    SoundPlayerInfo soundInfo = SmartVolManagerPackage.BgMusicManager.FindPlayerInfo(musicId);
                    if (soundInfo.Name == "System Sounds")
                    {
                        MessageBox.Show("You cannot set this sound as your background music.");
                        Cursor.Current = Cursors.Default;
                        return(false);
                    }
                    UiCommands.OnOperation(musicId, Operation.ChangeMusic, "", false, true);
                    UpdateBgMusicUI();
                }
            }
            catch (Exception ex)
            {
                MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
            }
            Cursor.Current = Cursors.Default;

            return(true);
        }
Esempio n. 8
0
        private void mResetSettingsMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(this, "Are you sure you want to reset mute.fm settings (both preferences and sound information) to the factory default?", Constants.ProgramName, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
            {
                UiCommands.OnOperation(Operation.Stop);

                try
                {
                    System.IO.File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\mute.fm\config.json");
                }
                catch (Exception ex)
                {
                    SmartVolManagerPackage.SoundEventLogger.LogException(ex);
                }

                /* // Not possible without closing down awesomium
                 * if (MessageBox. Show("Do you also want to clear the mute.fm browser cache?  This will free up space but may require setting up accounts for music services again.", Constants.ProgramName, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                 * {
                 *  try
                 *  {
                 *      System.IO.Directory.Delete(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\" + Constants.ProgramName + @"\Awesomium", true);
                 *  }
                 *  catch (Exception ex)
                 *  {
                 *      SmartVolManagerPackage.SoundEventLogger.LogException(ex);
                 *  }
                 * }*/

                SmartVolManagerPackage.BgMusicManager.Init(true);

                reloadIconsToolStripMenuItem_Click(null, null); // Regenerate icons just in case

                MessageBox.Show(null, "Settings were reset!  Press OK to quit and then rerun to experience original settings.", Constants.ProgramName);
                UiCommands.mPlayerForm.Exit(false);

                //UiCommands.OnOperation(Operation.Play);
                //UiCommands.UpdateUiForState();
            }
        }
Esempio n. 9
0
 private void mBgMusicIcon_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(Operation.Show);
 }
Esempio n. 10
0
        private void gettingStartedToolStripMenuItem_Click(object sender, EventArgs e)
        {
#if !NOAWE
            UiCommands.ShowGettingStartedWizard();
#endif
        }
Esempio n. 11
0
 private void mUnmuteButton_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(Operation.Unmute);
 }
Esempio n. 12
0
 private void mUnmuteButton_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(_musicId, Operation.Unmute, "", false, true);
 }
Esempio n. 13
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (_statusClearDateTime < DateTime.Now)
            {
                bool fgSound          = SmartVolManagerPackage.BgMusicManager.ForegroundSoundPlaying;
                bool bgSound          = SmartVolManagerPackage.BgMusicManager.BgMusicHeard;
                bool automuted        = SmartVolManagerPackage.BgMusicManager.AutoMuted;
                bool userWantsSound   = SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic;
                bool automuteDisabled = !SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.AutoMuteEnabled;

                // TODO: be careful for bg in comparing between what is supposed to play and actually playing.

                // TODO: consider case when automuting is disabled.  Then, choices should be: Playing or click play to listen to music

                if (!fgSound || !automuted) // i.e. background music can play right now
                {
                    // TODO: if music can't be heard for n seconds, tell user to interact with it; assumes 'bgsound' means that bgsound should be playing.
                    if (bgSound)
                    {
                        SetStatusText("Music playing...");
                        cannotHearStartDateTime     = DateTime.MinValue;
                        cannotHearNotificationShown = false;
                    }
                    else
                    {
                        if ((userWantsSound) && (!fgSound))
                        {
                            if (DateTime.Now.Subtract(cannotHearStartDateTime).TotalSeconds > 60)
                            {
                                cannotHearStartDateTime     = DateTime.Now; // new event
                                cannotHearNotificationShown = false;
                            }

                            // We will show a notification if we haven't heard anything for seven seconds and we haven't shown the user this warning over the past 60 seconds.
                            if (SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.NotifyWhenNoMusicToPlay && ((cannotHearNotificationShown == false) && (DateTime.Now.Subtract(cannotHearStartDateTime).TotalSeconds > 10)))
                            {
                                string notificationTypeSpecificText = "";
                                if (GrowlInstallHelper.GrowlInstallHelper.GetForceGrowl())
                                {
                                    notificationTypeSpecificText = "Click here to launch the player";
                                }
                                else
                                {
                                    notificationTypeSpecificText = "Launch the player";
                                }
                                UiCommands.SetNotification("Music expected. " + notificationTypeSpecificText + " (then Play or add more music) or Stop or disable this notification.", false);
                                //Maybe you need to add more to the playlist or click through an ad.  Click here to interact with player.  Or if you don't want music click Stop.  You can remove this message in the Notifications menu.", false);

                                //Cannot hear anything.  Either wait for music to play, click here to interact with player, or stop the music.", false);
                                cannotHearNotificationShown = true;
                            }

                            SetStatusText("Cannot hear anything.  Either wait for music to play or interact with music player.");
                        }
                        else
                        {
                            SetStatusText("Click 'Play' to listen to music.  You can choose your source by clicking 'Change'.");
                        }
                    }
                }
                else
                {
                    if (fgSound && !automuteDisabled)
                    {
                        if (userWantsSound)
                        {
                            TimeSpan span          = DateTime.Now - SmartVolManagerPackage.BgMusicManager.EffectiveSilenceDateTime;
                            int      remainingTime = (int)(SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.SilentDuration - span.TotalSeconds);
                            if (((remainingTime < (int)(SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.SilentDuration) - 1) && (remainingTime > 0) && SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic) && (SmartVolManagerPackage.BgMusicManager.DisableAutomuteTemporarily == false))
                            {
                                string str = "Music will resume after " + remainingTime.ToString() + " second" + ((remainingTime == 1) ? "" : "s") + " of silence or when you click Play.";
                                SetStatusText(str);
                            }
                            else
                            {
                                SetStatusText("Music automuted. To play, mute/ignore foreground sounds or disable automute.");
                            }
                        }
                        else
                        {
                            SetStatusText("Click 'Play' to have music play after foreground sounds finish.");
                        }
                    }
                    else
                    {
                        SetStatusText("Click 'Play' to listen to music.  You can choose your source by clicking 'Change'.");
                    }
                }
                _statusClearDateTime = DateTime.MinValue;
            }
        }
Esempio n. 14
0
 private void mDislikeButton_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(Operation.Dislike);
 }
Esempio n. 15
0
        private static void Hook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            if (DateTime.Now.Subtract(_lastKeyPress).TotalMilliseconds < 200) // Don't allow rapid keypresses
            {
                return;
            }

            _lastKeyPress = DateTime.Now;

            long key = (long)e.Key;

            if (0 != (e.Modifier & ModifierKeys.Alt))
            {
                key |= (long)Keys.Alt;
            }
            if (0 != (e.Modifier & ModifierKeys.Control))
            {
                key |= (long)Keys.Control;
            }
            if (0 != (e.Modifier & ModifierKeys.Shift))
            {
                key |= (long)Keys.Shift;
            }
            if (0 != (e.Modifier & ModifierKeys.Win))
            {
                key |= (long)Keys.LWin;
            }

            for (int i = 0; i < SmartVolManagerPackage.BgMusicManager.MuteFmConfig.Hotkeys.Length; i++)
            {
                Hotkey hotkey = SmartVolManagerPackage.BgMusicManager.MuteFmConfig.Hotkeys[i];
                if (hotkey.Key == key)
                {
                    switch (hotkey.Name.ToLower())
                    {
                    case "play":
                        UiCommands.OnOperation(Operation.Play);
                        break;

                    case "pause":
                        UiCommands.OnOperation(Operation.Pause);
                        break;

                    case "stop":
                        UiCommands.OnOperation(Operation.Stop);
                        break;

                    case "mute":
                        UiCommands.OnOperation(Operation.Mute);
                        break;

                    case "unmute":
                        UiCommands.OnOperation(Operation.Unmute);
                        break;

                    case "previous track":
                        UiCommands.OnOperation(Operation.PrevTrack);
                        break;

                    case "next track":
                        UiCommands.OnOperation(Operation.NextTrack);
                        break;

                    case "show":
                        UiCommands.OnOperation(Operation.Show);
                        break;

                    case "toggle muting music/videos":     // Could add this to enumeration
                        SmartVolManagerPackage.BgMusicManager.ToggleFgMute();
                        UiCommands.OnOperation(Operation.Restore);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Esempio n. 16
0
 private static void CloseBrowser()
 {
     UiCommands.CloseGettingStartedWizard();
 }
Esempio n. 17
0
 private void mNextTrackButton_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(Operation.NextTrack);
 }
Esempio n. 18
0
 private void mPlayButton_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(Operation.Play);
 }
Esempio n. 19
0
 private void mFgMusicIcon_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(_musicId, Operation.Show, "", false, true);
 }
Esempio n. 20
0
 private void mStopButton_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(Operation.Stop);
 }
Esempio n. 21
0
 private void mUncheckButton_Click(object sender, EventArgs e)
 {
     UiCommands.OnOperation(_musicId, Operation.IgnoreForAutoMute, "", false, true);
 }
Esempio n. 22
0
 private void OnHideMixer(object sender, EventArgs e)
 {
     UiCommands.HideMixer();
     UpdateTrayMenu(_validOperation, _isBgMusicVisible, _isRunning, false);
 }