Esempio n. 1
0
        private TabPage CreateButtonsPage()
        {
            bindings = Collection.ToArray(
                Collection.Range(4, () => new ComboBox()));
            var actions = HardwareButtonBindings.GetActions();
            var index   = 0;

            foreach (var item in bindings)
            {
                Layout.Resize(item);
                item.Items.Add("None");
                foreach (var name in actions)
                {
                    item.Items.Add(name);
                }
                var selected = HardwareButtonBindings.GetBinding(HardwareButtonBindings.Buttons[index]);
                item.SelectedItem =
                    (selected != string.Empty && item.Items.Contains(selected)) ?
                    selected : "None";
                index += 1;
            }

            var buttonsTable = Layout.Stack(
                Layout.Label("Hardware button 1"), bindings[0],
                Layout.Label("Hardware button 2"), bindings[1],
                Layout.Label("Hardware button 3"), bindings[2],
                Layout.Label("Hardware button 4"), bindings[3]);

            var page = new TabPage()
            {
                Text = "Buttons",
                Dock = DockStyle.Fill
            };

            Layout.Bind(buttonsTable, page);
            return(page);
        }
Esempio n. 2
0
        private void OnApplyClick(object sender, EventArgs args)
        {
            if (accountsBox.SelectedIndex >= 0)
            {
                ConfigManager.Settings.CurrentAccountName =
                    accountsBox.SelectedItem as string;
            }

            if (fontBox.SelectedIndex >= 0)
            {
                var name = fontBox.Items[fontBox.SelectedIndex] as string;
                if (name != ConfigManager.Settings.DefaultFontName)
                {
                    ConfigManager.Settings.DefaultFontName = name;
                }
            }

            if (encodingBox.SelectedIndex >= 0)
            {
                var name = encodingBox.Items[encodingBox.SelectedIndex] as string;
                if (name != ConfigManager.Settings.DefaultEncodingName)
                {
                    ConfigManager.Settings.DefaultEncodingName = name;
                }
            }

            if (gdiButton.Checked)
            {
                ConfigManager.ChangeRenderer(RendererType.GDI);
            }
            else if (direct3DButton.Checked)
            {
                ConfigManager.ChangeRenderer(RendererType.Direct3D);
            }

            ConfigManager.Settings.NoTextures    = textureBox.Checked;
            ConfigManager.Settings.KeepCursor    = cursorBox.Checked;
            ConfigManager.Settings.OldMark       = moveMarkBox.Checked;
            ConfigManager.Settings.FriendsNotify = friendsBox.Checked;
            ConfigManager.Settings.ChatNotify    = chatBox.Checked;
            ConfigManager.Settings.Sound         = soundBox.Checked;

            for (var i = 0; i < bindings.Length; i++)
            {
                if ((string)bindings[i].SelectedItem != "None")
                {
                    HardwareButtonBindings.Bind(
                        HardwareButtonBindings.Buttons[i],
                        (string)bindings[i].SelectedItem);
                }
                else
                {
                    HardwareButtonBindings.Unbind(
                        HardwareButtonBindings.Buttons[i]);
                }
            }

            ConfigManager.Settings.ButtonBindings =
                HardwareButtonBindings.GetBindings();

            if (Container != null)
            {
                Container.RemoveView(this);
            }

            ConfigManager.Save();
        }