Exemple #1
0
        private void HotKeyTextBox_TextChanged(object sender, EventArgs e)
        {
            String name  = ((TextBox)sender).Name;
            int    hossz = "keyCodeTextB".Length;

            name = name.Substring(hossz);

            int id = 0;

            int.TryParse(name, out id);

            id--;

            if (id >= 0 && id < SoundClass.HotkeyCount)
            {
                ((TextBox)sender).Text = SoundClass.GetHotkey(id).ToString();
            }

            textChanged = true;
            if (AutoSaveCb.Checked)
            {
                SaveSettings(true);
                textChanged = false;
            }
        }
Exemple #2
0
 private void SettingsForm_Resize(object sender, EventArgs e)
 {
     if (WindowState == FormWindowState.Minimized)
     {
         if (!Program.debugmode)
         {
             Hide();
         }
     }
     else
     {
         this.SoundTextBox1.Text  = SoundClass.GetPath(0);
         this.SoundTextBox2.Text  = SoundClass.GetPath(1);
         this.SoundTextBox3.Text  = SoundClass.GetPath(2);
         this.SoundTextBox4.Text  = SoundClass.GetPath(3);
         this.SoundTextBox5.Text  = SoundClass.GetPath(4);
         this.SoundTextBox6.Text  = SoundClass.GetPath(5);
         this.SoundTextBox7.Text  = SoundClass.GetPath(6);
         this.SoundTextBox8.Text  = SoundClass.GetPath(7);
         this.SoundTextBox9.Text  = SoundClass.GetPath(8);
         this.SoundTextBox10.Text = SoundClass.GetPath(9);
         this.SoundTextBox11.Text = SoundClass.GetPath(10);
         this.SoundTextBox12.Text = SoundClass.GetPath(11);
     }
 }
Exemple #3
0
        private void HotKeyTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            Keys   key         = e.KeyCode;
            Hotkey pressedKeys = new Hotkey();

            if (e.Modifiers.ToString().Contains(Keys.Control.ToString()))
            {
                pressedKeys.Add(Keys.Control);
            }
            if (e.Modifiers.ToString().Contains(Keys.Shift.ToString()))
            {
                pressedKeys.Add(Keys.Shift);
            }
            if (e.Modifiers.ToString().Contains(Keys.Alt.ToString()))
            {
                pressedKeys.Add(Keys.Alt);
            }

            bool doNotAdd = false;

            if (key.ToString().Contains(Keys.Control.ToString()))
            {
                doNotAdd = true;
            }
            if (key.ToString().Contains(Keys.Shift.ToString()))
            {
                doNotAdd = true;
            }
            if (key.ToString().Contains(Keys.Alt.ToString()))
            {
                doNotAdd = true;
            }

            if (!doNotAdd)
            {
                pressedKeys.Add(key);
            }

            String name  = ((TextBox)sender).Name;
            int    hossz = "keyCodeTextB".Length;

            name = name.Substring(hossz);

            int id = 0;

            int.TryParse(name, out id);

            id--;

            if (id >= 0 && id <= SoundClass.HotkeyCount)
            {
                SoundClass.SetHotkey(id, pressedKeys);

                ((TextBox)sender).Text = SoundClass.GetHotkey(id).ToString();
            }
            ChangeTextboxTexts();
        }
Exemple #4
0
        private void PlayBtn_Click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            String index_s = button.Name.Substring("PlayBtn".Length);
            int    index   = int.Parse(index_s);

            SoundClass.Play(index - 1);
        }
Exemple #5
0
 private void ChangeTextboxTexts()
 {
     keyCodeTextB1.Text  = SoundClass.GetHotkey(0).ToString();
     keyCodeTextB2.Text  = SoundClass.GetHotkey(1).ToString();
     keyCodeTextB3.Text  = SoundClass.GetHotkey(2).ToString();
     keyCodeTextB4.Text  = SoundClass.GetHotkey(3).ToString();
     keyCodeTextB5.Text  = SoundClass.GetHotkey(4).ToString();
     keyCodeTextB6.Text  = SoundClass.GetHotkey(5).ToString();
     keyCodeTextB7.Text  = SoundClass.GetHotkey(6).ToString();
     keyCodeTextB8.Text  = SoundClass.GetHotkey(7).ToString();
     keyCodeTextB9.Text  = SoundClass.GetHotkey(8).ToString();
     keyCodeTextB10.Text = SoundClass.GetHotkey(9).ToString();
     keyCodeTextB11.Text = SoundClass.GetHotkey(10).ToString();
     keyCodeTextB12.Text = SoundClass.GetHotkey(11).ToString();
 }
Exemple #6
0
        // CONSTRUKTOR
        public SettingsForm()
        {
            InitializeComponent();

            if (!NetworkBit)
            {
                ipAddressTB.Visible = false;
                toNetworkCB.Visible = false;
            }
            if (!ManageNetworkBit)
            {
                remoteControlCB.Visible   = false;
                ignoreBroadcastCB.Visible = false;
                remoteControl             = true;
                ignoreBroadcast           = false;
            }


            SoundClass.ClearHotkeys();
            for (int i = 0; i < 12; i++)
            {
                SoundClass.SetHotkey(new Hotkey("Control + Shift + F" + (i + 1)));
            }

            LoadSettings();

            SoundClass.Form = this;

            play_timer.Tick += new EventHandler(play_timer_Tick);

            if (!Program.debugmode)
            {
                this.WindowState = FormWindowState.Minimized;
            }

            Initialized = true;

            SaveSettings(false);

            NetworkClass.StartReceiving();

            KeyWatcher.ButtonPushed += new KeyWatcher.ButtonPushedEventHandler(ButtonPushedEvent);
        }
Exemple #7
0
        // Data decoding
        private static void DataReceived(byte[] data)
        {
            int index = -1;

            if (data.Length >= 2)
            {
                String[] sData    = Encoding.ASCII.GetString(data).Split(';');
                String   playType = sData[0];               // Normal / Hard

                index = int.Parse(sData[1]);                // should be a number

                if (index >= 0 && index < SoundClass.SoundsCount)
                {
                    if (String.Compare(playType, "Normal") == 0)
                    {
                        SoundClass.Play(index);
                    }
                    else if (String.Compare(playType, "Hard") == 0)
                    {
                        SoundClass.HardPlay(index);
                    }
                }
            }
        }
Exemple #8
0
        private void SaveSettings(bool soundSave)
        {
            if (!Initialized)
            {
                return;
            }

            #region Sounds mentés
            if (soundSave)
            {
                try { Registry.CurrentUser.DeleteSubKey(regSoundsPath); }
                catch { }

                RegistryKey rSoundskey = Registry.CurrentUser.CreateSubKey(regSoundsPath);
                if (rSoundskey != null)
                {
                    try
                    {
                        SoundClass.ClearSounds();
                        SoundClass.SetPath(this.SoundTextBox1.Text);
                        SoundClass.SetPath(this.SoundTextBox2.Text);
                        SoundClass.SetPath(this.SoundTextBox3.Text);
                        SoundClass.SetPath(this.SoundTextBox4.Text);
                        SoundClass.SetPath(this.SoundTextBox5.Text);
                        SoundClass.SetPath(this.SoundTextBox6.Text);
                        SoundClass.SetPath(this.SoundTextBox7.Text);
                        SoundClass.SetPath(this.SoundTextBox8.Text);
                        SoundClass.SetPath(this.SoundTextBox9.Text);
                        SoundClass.SetPath(this.SoundTextBox10.Text);
                        SoundClass.SetPath(this.SoundTextBox11.Text);
                        SoundClass.SetPath(this.SoundTextBox12.Text);

                        for (int i = 0; i < SoundClass.SoundsCount; i++)
                        {
                            rSoundskey.SetValue("Sound_" + (i + 1), SoundClass.GetPath(i));
                        }

                        textChanged = false;
                    }
                    catch (Exception ex)
                    {
                        String message = "";
                        message += "Error during saving!\n";
                        message += "Exception caught! Exception Type: : \t" + ex.GetType().ToString() + "\n";
                        message += "Exception message:\n";
                        message += ex.Message;
                        if (ex.InnerException != null)
                        {
                            message += "Inner Exception Type: : \t" + ex.InnerException.GetType().ToString() + "\n";
                            message += "Inner Exception message:\n";
                            message += ex.InnerException.Message;
                        }
                        MessageBox.Show(message);
                    }
                }
            }
            #endregion

            #region Settings mentés
            try { Registry.CurrentUser.DeleteSubKey(regSettingsPath); }
            catch { }

            RegistryKey rSettingskey = Registry.CurrentUser.CreateSubKey(regSettingsPath);
            if (rSettingskey != null)
            {
                try
                {
                    justMinimize    = this.justMinimizeCb.Checked;
                    autosave        = this.AutoSaveCb.Checked;
                    animate         = this.AnimateCb.Checked;
                    remoteControl   = this.remoteControlCB.Checked;
                    ignoreBroadcast = this.ignoreBroadcastCB.Checked;

                    rSettingskey.SetValue("justMinimize", this.justMinimizeCb.Checked);
                    rSettingskey.SetValue("AutoSave", this.AutoSaveCb.Checked);
                    rSettingskey.SetValue("AutoStart", this.startupCb.Checked);
                    rSettingskey.SetValue("AnimateSystemTray", this.AnimateCb.Checked);
                    rSettingskey.SetValue("RemoteControl", this.remoteControlCB.Checked);
                    rSettingskey.SetValue("IgnoreBroadcast", this.ignoreBroadcastCB.Checked);

                    SoundClass.ClearHotkeys();
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB1.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB2.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB3.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB4.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB5.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB6.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB7.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB8.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB9.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB10.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB11.Text));
                    SoundClass.SetHotkey(new Hotkey(keyCodeTextB12.Text));

                    for (int i = 0; i < SoundClass.HotkeyCount; i++)
                    {
                        rSettingskey.SetValue("ShortcutKey_" + i, SoundClass.GetHotkey(i));
                    }
                }
                catch (Exception ex)
                {
                    String message = "";
                    message += "Error during saving!\n";
                    message += "Exception caught! Exception Type: : \t" + ex.GetType().ToString() + "\n";
                    message += "Exception message:\n";
                    message += ex.Message;
                    if (ex.InnerException != null)
                    {
                        message += "Inner Exception Type: : \t" + ex.InnerException.GetType().ToString() + "\n";
                        message += "Inner Exception message:\n";
                        message += ex.InnerException.Message;
                    }
                    MessageBox.Show(message);
                }
            }
            #endregion
        }
Exemple #9
0
        private void LoadSettings()
        {
            #region Sounds betöltés
            RegistryKey rSoundskey = Registry.CurrentUser.OpenSubKey(regSoundsPath);
            if (rSoundskey != null)
            {
                try
                {
                    SoundClass.ClearSounds();
                    for (int i = 0; i < 12; i++)
                    {
                        String tempValue = (String)rSoundskey.GetValue("Sound_" + (i + 1));
                        SoundClass.SetPath(tempValue);
                    }

                    this.SoundTextBox1.Text  = SoundClass.GetPath(0);
                    this.SoundTextBox2.Text  = SoundClass.GetPath(1);
                    this.SoundTextBox3.Text  = SoundClass.GetPath(2);
                    this.SoundTextBox4.Text  = SoundClass.GetPath(3);
                    this.SoundTextBox5.Text  = SoundClass.GetPath(4);
                    this.SoundTextBox6.Text  = SoundClass.GetPath(5);
                    this.SoundTextBox7.Text  = SoundClass.GetPath(6);
                    this.SoundTextBox8.Text  = SoundClass.GetPath(7);
                    this.SoundTextBox9.Text  = SoundClass.GetPath(8);
                    this.SoundTextBox10.Text = SoundClass.GetPath(9);
                    this.SoundTextBox11.Text = SoundClass.GetPath(10);
                    this.SoundTextBox12.Text = SoundClass.GetPath(11);

                    textChanged = false;
                }
                catch (Exception ex)
                {
                    String message = "";
                    message += "Error during loading sounds!\n";
                    message += "Exception caught! Exception Type: : \t" + ex.GetType().ToString() + "\n";
                    message += "Exception message:\n";
                    message += ex.Message;
                    if (ex.InnerException != null)
                    {
                        message += "Inner Exception Type: : \t" + ex.InnerException.GetType().ToString() + "\n";
                        message += "Inner Exception message:\n";
                        message += ex.InnerException.Message;
                    }
                    MessageBox.Show(message);
                }
            }
            #endregion

            #region Settings betöltés
            RegistryKey rSettingskey = Registry.CurrentUser.OpenSubKey(regSettingsPath);
            if (rSettingskey != null)
            {
                try
                {
                    String check = (String)rSettingskey.GetValue("justMinimize");
                    this.justMinimizeCb.Checked = bool.Parse(check);
                    justMinimize = this.justMinimizeCb.Checked;

                    check = (String)rSettingskey.GetValue("AutoSave");
                    this.AutoSaveCb.Checked = bool.Parse(check);
                    autosave = this.AutoSaveCb.Checked;

                    check = (String)rSettingskey.GetValue("AutoStart");
                    this.startupCb.Checked = bool.Parse(check);

                    check = (String)rSettingskey.GetValue("AnimateSystemTray");
                    this.AnimateCb.Checked = bool.Parse(check);
                    animate = this.AnimateCb.Checked;

                    check = (String)rSettingskey.GetValue("RemoteControl");
                    this.remoteControlCB.Checked = bool.Parse(check);
                    remoteControl = this.remoteControlCB.Checked;

                    check = (String)rSettingskey.GetValue("IgnoreBroadcast");
                    this.ignoreBroadcastCB.Checked = bool.Parse(check);
                    ignoreBroadcast = this.ignoreBroadcastCB.Checked;


                    String hotkey;
                    SoundClass.ClearHotkeys();
                    for (int i = 0; i < 12; i++)
                    {
                        hotkey = (String)rSettingskey.GetValue("ShortcutKey_" + i);
                        if (hotkey != null)
                        {
                            SoundClass.SetHotkey(new Hotkey(hotkey));
                        }
                    }

                    ChangeTextboxTexts();
                }
                catch (Exception ex)
                {
                    String message = "";
                    message += "Error during loading settings!\n";
                    message += "Exception caught! Exception Type: : \t" + ex.GetType().ToString() + "\n";
                    message += "Exception message:\n";
                    message += ex.Message;
                    if (ex.InnerException != null)
                    {
                        message += "Inner Exception Type: : \t" + ex.InnerException.GetType().ToString() + "\n";
                        message += "Inner Exception message:\n";
                        message += ex.InnerException.Message;
                    }
                    MessageBox.Show(message);
                }
            }
            #endregion
        }
Exemple #10
0
        public static void PushedButtons(int keyCode)
        {
            if (Program.debugmode)
            {
                String realPressed = "";
                realPressed += "vkCode: " + keyCode + " \n";
                realPressed += "Key: " + (Keys)keyCode + " \n";
                realPressed += "ModifierKeys: " + Control.ModifierKeys + " \n";
                Console.WriteLine(realPressed);
            }

            Keys   key         = (Keys)keyCode;
            Hotkey pressedKeys = new Hotkey();

            if (Control.ModifierKeys.ToString().Contains(Keys.Control.ToString()))
            {
                pressedKeys.Add(Keys.Control);
            }
            if (Control.ModifierKeys.ToString().Contains(Keys.Shift.ToString()))
            {
                pressedKeys.Add(Keys.Shift);
            }
            if (Control.ModifierKeys.ToString().Contains(Keys.Alt.ToString()))
            {
                pressedKeys.Add(Keys.Alt);
            }

            bool doNotAdd = false;

            if (key.ToString().Contains(Keys.Control.ToString()))
            {
                doNotAdd = true;
            }
            if (key.ToString().Contains(Keys.Shift.ToString()))
            {
                doNotAdd = true;
            }
            if (key.ToString().Contains(Keys.Alt.ToString()))
            {
                doNotAdd = true;
            }

            if (!doNotAdd)
            {
                pressedKeys.Add(key);
            }

            /* HARD CODED EXIT COMBO */
            Hotkey exitCombo = new Hotkey("Control + Shift + Alt + Delete");

            if (pressedKeys.Equals(exitCombo))
            {
                SettingsForm.forceClose = true;
                Application.Exit();
            }
            /* HARD CODED EXIT COMBO */

            ButtonPushed(pressedKeys);

            for (int i = 0; i < SoundClass.HotkeyCount; i++)
            {
                if (pressedKeys.Equals(SoundClass.GetHotkey(i)))
                {
                    if (SettingsForm.ToNetwork)
                    {
                        NetworkClass.Send(i.ToString());
                    }
                    else
                    {
                        if (NetworkClass.hardPlay && Program.godmode)
                        {
                            SoundClass.HardPlay(i);
                        }
                        else
                        {
                            SoundClass.Play(i);
                        }
                    }
                }
            }

            if (Program.debugmode)
            {
                Console.WriteLine(pressedKeys.ToString());
            }
        }