示例#1
0
 private void kbh_OnKeyPressed(object sender, VirtualKeyShort e)
 {
     if (e == VirtualKeyShort.VOLUME_UP || e == VirtualKeyShort.VOLUME_DOWN ||
         e == VirtualKeyShort.VOLUME_MUTE ||
         e == VirtualKeyShort.MEDIA_NEXT_TRACK || e == VirtualKeyShort.MEDIA_PREV_TRACK ||
         e == VirtualKeyShort.MEDIA_PLAY_PAUSE || e == VirtualKeyShort.MEDIA_STOP)
     {
         VolumeSMTC.FindSMTCAndHide(); //Is this CPU expensive?
         w.Show();
     }
 }
示例#2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (!mutex.WaitOne(TimeSpan.Zero, true))
            {
                //You may want to hide Volume HUD (again?)
                VolumeSMTC.ForceFindSMTCAndHide();

                Environment.Exit(0);
                return; //UwU
            }

            VolumeSMTC.ForceFindSMTCAndHide();

            //Flyout
            vlFly = new MainWindow();
            vlFly.HideFlyoutButton.Click += HideFlyoutButton_Click;
            vlFly.MovableAreaBorder.MouseLeftButtonDown += MovableAreaBorder_MouseLeftButtonDown;
            vlFly.MouseEnter += VlFly_MouseEnter;
            vlFly.MouseLeave += VlFly_MouseLeave;

            //Audio Device
            client = new AudioDeviceNotificationClient();
            client.DefaultDeviceChanged += Client_DefaultDeviceChanged;

            enumerator = new MMDeviceEnumerator();
            enumerator.RegisterEndpointNotificationCallback(client);

            if (enumerator.HasDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia))
            {
                vlFly.UpdateDevice(enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia));
            }

            //Windows In Band Wrapper
            w = new WindowInBandWrapper(vlFly);
            w.CreateWindowInBand();
            w.SetWindowPosition(48, 48);

            //Key hook
            kbh = new HookEngine();
            kbh.OnKeyPressed += kbh_OnKeyPressed;
            kbh.HookKeyboard();

            //Kind of shutdown
            ShutdownMode = ShutdownMode.OnExplicitShutdown;
        }