Beispiel #1
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();
        }
Beispiel #2
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);
        }
Beispiel #3
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
        }
Beispiel #4
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
        }