示例#1
0
        protected override void OnFormClosed(FormClosedEventArgs e)
        {
            try
            {

                var vol = VolumeMixer.GetApplicationVolume(Process.GetCurrentProcess().Id);
                if (vol.HasValue)
                {
                    Properties.Settings.Default["Volume"] = vol.Value;
                    Properties.Settings.Default.Save();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unable to store the volume settings: " + ex.GetType().FullName + " - " + ex.Message);
            }
            base.OnFormClosed(e);
        }
示例#2
0
        private void tmrUpdateInfo_Tick(object sender, EventArgs e)
        {
            if (browser.ReadyState == WebBrowserReadyState.Complete)
            {
                if (!isBrowserLoadedForTheFirstTime)
                {

                    Timer tmrVolumeDefaultSet = new Timer();
                    tmrVolumeDefaultSet.Tick += (s, ev) =>
                    {
                        tmrVolumeDefaultSet.Stop();
                        try
                        {

                            float vol = (float)Properties.Settings.Default.Volume;
                            if (vol == 0)
                                vol = 10;
                            VolumeMixer.SetApplicationVolume(Process.GetCurrentProcess().Id, vol);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Unable to restore application volume: " + ex.GetType().FullName + " - " + ex.Message);
                        }
                    };
                    tmrVolumeDefaultSet.Interval = 10000;
                    tmrVolumeDefaultSet.Start();
                    isBrowserLoadedForTheFirstTime = true;
                }

                try
                {

                    string info;
                    if (ConfigurationManager.AppSettings["Version"] == "2")
                        info = this.browser.Document.InvokeScript("eval", new object[] { "API.getInfo()" }) + "";
                    else
                        info = this.browser.Document.InvokeScript("playerGetInfo") + "";

                    if (info.Length >= 64)
                        info = info.Substring(0, 60) + "...";

                    if (notifyIcon.BalloonTipText != info)
                    {
                        bool wasEmpty = string.IsNullOrEmpty(notifyIcon.BalloonTipText);
                        notifyIcon.BalloonTipText = info;

                        if (doPopupOnChange)
                        {
                            if (currentAnimState == AnimStateEnum.Idle && !wasEmpty)
                                ShowForm(false);
                            else
                                waitTimeout = WAIT_TICKS; // reset wait timeout
                        }
                    }
                    if (notifyIcon.Text != info)
                        notifyIcon.Text = info;
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("Unable to update tray text:" + ex.GetType().FullName + " - " + ex.Message);
                    // silently ignore
                }
            }



        }