コード例 #1
0
        private void FermerWinuntu()
        {
            //-----------------------------------------------
            // Empeche une erreur pendant la disposition des ressources
            TimerActualiserRAM.Stop();
            TimerActualiseNodes.Stop();
            TimerKeys.Stop();

            FermerToutesLesInstances();

            Application.Exit();
            //-----------------------------------------------
        }
コード例 #2
0
ファイル: frmPlayer.cs プロジェクト: bernardocervoz/player
 private void TimerKeys_Tick(object sender, EventArgs e)
 {
     if (Seconds > 0)
     {
         Seconds = 0;
         TimerKeys.Stop();
         SendText = false;
         Suspend  = false;
     }
     else
     {
         Seconds++;
     }
 }
コード例 #3
0
ファイル: frmPlayer.cs プロジェクト: bernardocervoz/player
        protected override void WndProc(ref Message m)
        {
            const int millisecondsTimeout = 500;

            try
            {
                if (m.Msg == Constants.WM_HOTKEY_MSG_ID)
                {
                    switch (GetKey(m.LParam))
                    {
                    case Keys.Enter:
                        if (!Suspend)
                        {
                            Keyboard.SendKey(Keys.MediaPlayPause);
                        }
                        break;

                    case Keys.Up:
                        if (!Suspend)
                        {
                            Keyboard.SendKey(Keys.VolumeUp);
                        }
                        break;

                    case Keys.Down:
                        if (!Suspend)
                        {
                            Keyboard.SendKey(Keys.VolumeDown);
                        }
                        break;

                    case Keys.Right:
                        if (!Suspend)
                        {
                            Keyboard.SendKey(Keys.MediaNextTrack);
                        }
                        break;

                    case Keys.Left:
                        if (!Suspend)
                        {
                            Keyboard.SendKey(Keys.MediaPreviousTrack);
                        }
                        break;

                    case Keys.Back:
                        if (!Suspend)
                        {
                            Keyboard.SendKey(Keys.VolumeMute);
                        }
                        break;

                    case Keys.P:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.P))
                        {
                            Process.Start(@hotkeys.P);
                        }
                        break;

                    case Keys.V:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.V))
                        {
                            Process.Start(@hotkeys.V);
                        }
                        break;

                    case Keys.O:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.O))
                        {
                            Process.Start(@hotkeys.O);
                        }
                        break;

                    case Keys.N:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.N))
                        {
                            Process.Start(@hotkeys.N);
                        }
                        break;

                    case Keys.S:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.S))
                        {
                            Process.Start(@hotkeys.S);
                        }
                        break;

                    case Keys.B:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.B))
                        {
                            Process.Start(@hotkeys.B);
                        }
                        break;

                    case Keys.C:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.C))
                        {
                            Process.Start(@hotkeys.C);
                        }
                        break;

                    case Keys.F:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.F))
                        {
                            Process.Start(@hotkeys.F);
                        }
                        break;

                    case Keys.W:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.W))
                        {
                            Process.Start(@hotkeys.W);
                        }
                        break;

                    case Keys.G:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.G))
                        {
                            Process.Start(@hotkeys.G);
                        }
                        break;

                    case Keys.I:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.I))
                        {
                            Process.Start(@hotkeys.I);
                        }
                        break;

                    case Keys.E:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.E))
                        {
                            Process.Start(@hotkeys.E);
                        }
                        break;

                    case Keys.U:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.U))
                        {
                            Process.Start(@hotkeys.U);
                        }
                        break;

                    case Keys.L:
                        if (!Suspend && hotkeys != null && !string.IsNullOrWhiteSpace(hotkeys.L))
                        {
                            Process.Start(@hotkeys.L);
                        }
                        break;

                    case Keys.NumPad1:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad1))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad1);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad2:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad2))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad2);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad3:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad3))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad3);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad4:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad4))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad4);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad5:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad5))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad5);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad6:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad6))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad6);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad7:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad7))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad7);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad8:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad8))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad8);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad9:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad9))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad9);
                            TimerKeys.Start();
                        }
                        break;

                    case Keys.NumPad0:
                        if (!Suspend && !string.IsNullOrWhiteSpace(hotkeys.NumPad0))
                        {
                            Suspend  = true;
                            SendText = true;
                            System.Threading.Thread.Sleep(millisecondsTimeout);
                            SendKeys.Send(hotkeys.NumPad0);
                            TimerKeys.Start();
                        }
                        break;
                    }
                }
                base.WndProc(ref m);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Player", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }