예제 #1
0
파일: BindControl.cs 프로젝트: maesse/HLSM
        public BindControl(Sound sound)
        {
            InitializeComponent();
            this.sound = sound;
            textBoxBind.Text = sound.BindToString();

            Hook.GetForm().InitKeyboard();
            timer = new Timer();
            timer.Interval = 16;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();

            toolTip1.SetToolTip(textBoxBind, "Bind already exists");
        }
예제 #2
0
파일: SoundItem.cs 프로젝트: maesse/HLSM
 public SoundItem(Sound sound)
 {
     InitializeComponent();
     this.sound = sound;
     SetFields();
     if (!Hook.GetForm().CheckWave(sound.Filename))
     {
         // Show warning
         toolTip1.SetToolTip(pictureBoxWarning, "Invalid Wav format");
         pictureBoxWarning.Visible = true;
     }
     else
     {
         toolTip1.RemoveAll();
         pictureBoxWarning.Visible = false;
     }
 }
예제 #3
0
파일: MainForm.cs 프로젝트: maesse/HLSM
        // Check binds
        void timer_Tick(object sender, EventArgs e)
        {
            if (lastBind != 0)
            {
                float time = (float)(HighResolutionTimer.Ticks-lastBind) / (float)HighResolutionTimer.Frequency * 1000f;
                if (time < 500f) // wait 500ms between accepting binds
                    return;
            }

            List<Key> keys = PollKeyboard();
            // Compare all binds against held keys
            bool ExclusiveKeys = Properties.Settings.Default.ExclusiveKeys;
            foreach (Sound sound in sounds.SoundList)
            {
                bool allDown = false;

                if (!ExclusiveKeys)
                {
                    foreach (Key bindKey in sound.Bind)
                    {
                        bool thisDown = false;
                        foreach (Key downKey in keys)
                        {
                            if (downKey == bindKey)
                            {
                                thisDown = true;
                                break;
                            }
                        }

                        if (!thisDown)
                            break;
                        else
                            allDown = true;
                    }
                }
                else
                {
                    int numFound = 0;
                    foreach (Key downKey in keys)
                    {
                        bool thisDown = false;
                        foreach (Key bindKey in sound.Bind)
                        {
                            if (downKey == bindKey)
                            {
                                thisDown = true;
                                numFound++;
                                break;
                            }
                        }

                        if (!thisDown)
                            break;
                        else if(numFound == sound.Bind.Count)
                            allDown = true;
                    }
                }

                // This bind has been activated...
                if (allDown && ActiveSound != sound && File.Exists(sound.Filename))
                {
                    ActiveSound = sound;
                    File.Copy(sound.Filename, Properties.Settings.Default.HLPath + "/" + Properties.Settings.Default.SoundDestName, true);
                    System.Console.WriteLine("Copying " + sound.Filename);
                    lastBind = HighResolutionTimer.Ticks;
                    break;
                }
            }
        }
예제 #4
0
파일: MainForm.cs 프로젝트: maesse/HLSM
 // stop listening, moving files, etc.
 public void Disable()
 {
     // Enable UI
     LockChanged(true);
     sounds = null;
     ActiveSound = null;
     if (timer != null)
         timer.Stop();
     CloseKeyboard();
 }