public ProjectMetadataScreen() { Logger.WriteEvent("ProjectMetadataScreen constructor"); InitializeComponent(); // position the Description and Vernacular label correctly var rowHeight = _tableLayout.GetRowHeights()[0]; _tableLayout.RowStyles[2].SizeType = SizeType.Absolute; _tableLayout.RowStyles[2].Height = rowHeight; _tableLayout.RowStyles[4].SizeType = SizeType.Absolute; _tableLayout.RowStyles[4].Height = rowHeight; // continent list var continentList = ListConstructor.GetClosedList(ListType.Continents, true, ListConstructor.RemoveUnknown.RemoveAll); _continent.DataSource = continentList; _continent.DisplayMember = "Text"; _continent.ValueMember = "Value"; SizeContinentComboBox(_continent); // Data-binding doesn't work correctly for country because it is an open list. // Items populated in HandleStringsLocalized. _countryList = ListConstructor.GetList(ListType.Countries, false, Localize, ListConstructor.RemoveUnknown.RemoveAll); _linkHelp.Click += (s, e) => Program.ShowHelpTopic("/User_Interface/Tabs/About_This_Project_User_Interface_terms.htm"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Update the tab text in case it was localized. /// </summary> /// ------------------------------------------------------------------------------------ protected override void HandleStringsLocalized() { TabText = LocalizationManager.GetString("SessionsView.MetadataEditor.TabText", "Session"); if (_genre != null && !String.IsNullOrEmpty(_genre.Text)) { var genreId = GenreDefinition.TranslateNameToId(_genre.Text); if (genreId != _genre.Text) { _genre.Text = GenreDefinition.TranslateIdToName(genreId); } } if (_gridAdditionalFields != null) { for (int iRow = 0; iRow < _gridAdditionalFields.RowCount; iRow++) { DataGridViewComboBoxCell comboBoxCell = _gridAdditionalFields[1, iRow] as DataGridViewComboBoxCell; if (comboBoxCell != null) { IMDIItemList list = comboBoxCell.DataSource as IMDIItemList; if (list != null) { list.Localize(Localize); } } } } base.HandleStringsLocalized(); }
/// --------------------------------------------------------------------------------------- /// <summary>Constructs a list of IMDIListItems that can be used as the data source of a /// combo or list box</summary> /// <param name="listName">Name of the XML file that contains the desired list. It is suggested to /// use values from IMDI_Schema.ListTypes class. If not found on the local system, we will attempt /// to download from http://www.mpi.nl/IMDI/Schema. /// </param> /// <param name="uppercaseFirstCharacter">Make first character of each item uppercase</param> /// <param name="localize">Delegate to use for getting localized versions of the Text and /// Definition of list items. The parameters are: 1) the list name; 2) list item value; /// 3) "Definition" or "Text"; 4) default (English) value.</param> /// <param name="removeUnknown">Specify which values of "unknown" to remove</param> public static IMDIItemList GetList(string listName, bool uppercaseFirstCharacter, Func<string, string, string, string, string> localize, RemoveUnknown removeUnknown) { listName = ListNameWithXmlExtension(listName); var listKey = listName + removeUnknown; IMDIItemList list; if (!_loadedLists.TryGetValue(listKey, out list)) { list = new IMDIItemList(listName, uppercaseFirstCharacter, removeUnknown); _loadedLists.Add(listKey, list); } list.Localize(localize); return list; }