private void PopulateKeyboardList() { if (_model == null || !_model.HasCurrentSelection) { _possibleKeyboardsList.Items.Clear(); return; } _possibleKeyboardsList.BeginUpdate(); Rectangle originalBounds = _possibleKeyboardsList.Bounds; _possibleKeyboardsList.Items.Clear(); _possibleKeyboardsList.Items.Add(MakeLabelItem( LocalizationManager.GetString("WSKeyboardControl.KeyboardsPreviouslyUsed", "Previously used keyboards"))); var unavailableFont = new Font(_possibleKeyboardsList.Font, FontStyle.Italic); foreach (var keyboard in _model.KnownKeyboards) { var adapter = new KeyboardDefinitionAdapter(keyboard); var item = new ListViewItem(adapter.ToString()); item.Tag = adapter; if (!keyboard.IsAvailable) { item.Font = unavailableFont; item.ForeColor = _unavailableColor; } item.ToolTipText = adapter.ToString(); _possibleKeyboardsList.Items.Add(item); if (keyboard == _model.CurrentKeyboard) { item.Selected = true; } } _possibleKeyboardsList.Items.Add(MakeLabelItem( LocalizationManager.GetString("WSKeyboardControl.KeyboardsAvailable", "Available keyboards"))); foreach (var keyboard in _model.OtherAvailableKeyboards) { var adapter = new KeyboardDefinitionAdapter(keyboard); var item = new ListViewItem(adapter.ToString()); item.Tag = adapter; item.ToolTipText = adapter.ToString(); _possibleKeyboardsList.Items.Add(item); } _possibleKeyboardsList.Bounds = originalBounds; _possibleKeyboardsList.EndUpdate(); }
private void UpdateFromModel() { if (_model == null || !_model.HasCurrentSelection) { Enabled = false; _selectKeyboardLabel.Visible = false; return; } Enabled = true; _selectKeyboardLabel.Visible = true; if (_selectKeyboardPattern == null) { _selectKeyboardPattern = _selectKeyboardLabel.Text; } _selectKeyboardLabel.Text = string.Format(_selectKeyboardPattern, _model.CurrentDefinition.ListLabel); KeyboardDefinitionAdapter currentKeyboardDefinition = null; if (_possibleKeyboardsList.SelectedItems.Count > 0) { currentKeyboardDefinition = _possibleKeyboardsList.SelectedItems[0].Tag as KeyboardDefinitionAdapter; } if (_model.CurrentKeyboard != null && (currentKeyboardDefinition == null || _model.CurrentKeyboard.Layout != currentKeyboardDefinition.Layout || _model.CurrentKeyboard.Locale != currentKeyboardDefinition.Locale)) { foreach (ListViewItem item in _possibleKeyboardsList.Items) { var keyboard = item.Tag as KeyboardDefinitionAdapter; if (keyboard != null && keyboard.Layout == _model.CurrentKeyboard.Layout && keyboard.Locale == _model.CurrentKeyboard.Locale) { //_possibleKeyboardsList.SelectedItems.Clear(); // We're updating the display from the model, so we don't need to run the code that // updates the model from the display. _possibleKeyboardsList.SelectedIndexChanged -= _possibleKeyboardsList_SelectedIndexChanged; item.Selected = true; // single select is true, so should clear any old one. _possibleKeyboardsList.SelectedIndexChanged += _possibleKeyboardsList_SelectedIndexChanged; break; } } } SetTestAreaFont(); }
private void PopulateKeyboardList() { if (_model == null || !_model.HasCurrentSelection) { _possibleKeyboardsList.Items.Clear(); return; } _possibleKeyboardsList.BeginUpdate(); Rectangle originalBounds = _possibleKeyboardsList.Bounds; _possibleKeyboardsList.Items.Clear(); _possibleKeyboardsList.Items.Add(MakeLabelItem( LocalizationManager.GetString("WSKeyboardControl.KeyboardsPreviouslyUsed", "Previously used keyboards"))); var unavailableFont = new Font(_possibleKeyboardsList.Font, FontStyle.Italic); foreach (var keyboard in _model.KnownKeyboards) { var adapter = new KeyboardDefinitionAdapter(keyboard); var item = new ListViewItem(adapter.ToString()); item.Tag = adapter; if (!keyboard.IsAvailable) { item.Font = unavailableFont; item.ForeColor = _unavailableColor; } item.ToolTipText = adapter.ToString(); _possibleKeyboardsList.Items.Add(item); if (keyboard == _model.CurrentKeyboard) item.Selected = true; } _possibleKeyboardsList.Items.Add(MakeLabelItem( LocalizationManager.GetString("WSKeyboardControl.KeyboardsAvailable", "Available keyboards"))); foreach (var keyboard in _model.OtherAvailableKeyboards) { var adapter = new KeyboardDefinitionAdapter(keyboard); var item = new ListViewItem(adapter.ToString()); item.Tag = adapter; item.ToolTipText = adapter.ToString(); _possibleKeyboardsList.Items.Add(item); } _possibleKeyboardsList.Bounds = originalBounds; _possibleKeyboardsList.EndUpdate(); }