private void _reslistbox_ItemSelected(Label item, Listbox sender)
 {
     if (vmList.ContainsKey(item.Text.Text))
     {
         VideoMode sel = vmList[item.Text.Text];
         ConfigurationManager.SetCVar("display.width", (int)sel.Width);
         ConfigurationManager.SetCVar("display.height", (int)sel.Height);
     }
 }
        private void InitalizeGUI()
        {
            _background = ResourceCache.GetSprite("mainbg");
            _ticketBg   = ResourceCache.GetSprite("ticketoverlay");

            _lblTitle = new Label("Options", "CALIBRI", 48, ResourceCache);
            UserInterfaceManager.AddComponent(_lblTitle);

            _lblFullscreen = new Label("Fullscreen", "CALIBRI", ResourceCache);
            UserInterfaceManager.AddComponent(_lblFullscreen);

            _chkFullscreen = new Checkbox(ResourceCache);
            _chkFullscreen.ValueChanged += _chkfullscreen_ValueChanged;
            _chkfullscreen_ValueChanged(ConfigurationManager.GetCVar <bool>("display.fullscreen"), _chkFullscreen);
            UserInterfaceManager.AddComponent(_chkFullscreen);

            _lblVsync = new Label("Vsync", "CALIBRI", ResourceCache);
            UserInterfaceManager.AddComponent(_lblVsync);

            _chkVsync = new Checkbox(ResourceCache);
            _chkVsync.ValueChanged += _chkvsync_ValueChanged;
            _chkvsync_ValueChanged(ConfigurationManager.GetCVar <bool>("display.vsync"), _chkVsync);
            UserInterfaceManager.AddComponent(_chkVsync);

            _lstResolution = new Listbox(250, 150, ResourceCache);
            _lstResolution.ItemSelected += _reslistbox_ItemSelected;
            PopulateAvailableVideoModes();
            UserInterfaceManager.AddComponent(_lstResolution);

            _btnBack          = new Button("Back", ResourceCache);
            _btnBack.Clicked += _backBtn_Clicked;
            UserInterfaceManager.AddComponent(_btnBack);

            _btnApply          = new Button("Apply Settings", ResourceCache);
            _btnApply.Clicked += _applybtt_Clicked;
            UserInterfaceManager.AddComponent(_btnApply);

            UpdateGUIPosition();
        }