private static int CompareTrlItems(KeyValuePair <string, KPTranslation> a, KeyValuePair <string, KPTranslation> b) { KPTranslationProperties pA = a.Value.Properties; KPTranslationProperties pB = b.Value.Properties; int c = StrUtil.CompareNaturally(pA.NameEnglish, pB.NameEnglish); if (c != 0) { return(c); } c = StrUtil.CompareNaturally(pA.NameNative, pB.NameNative); if (c != 0) { return(c); } c = StrUtil.CompareNaturally(pA.ApplicationVersion, pB.ApplicationVersion); if (c != 0) { return((c < 0) ? 1 : -1); // Descending } return(string.Compare(a.Key, b.Key, StrUtil.CaseIgnoreCmp)); }
private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this, this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_Keyboard_Layout, KPRes.SelectLanguage, KPRes.SelectLanguageDesc); this.Icon = AppIcons.Default; this.Text = KPRes.SelectLanguage; UIUtil.SetExplorerTheme(m_lvLanguages, true); List <Image> lImg = new List <Image>(); lImg.Add(Properties.Resources.B16x16_Browser); m_ilIcons = UIUtil.BuildImageListUnscaled(lImg, DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16)); m_lvLanguages.SmallImageList = m_ilIcons; m_lvLanguages.Columns.Add(KPRes.InstalledLanguages); m_lvLanguages.Columns.Add(KPRes.Version); m_lvLanguages.Columns.Add(KPRes.Author); m_lvLanguages.Columns.Add(KPRes.Contact); m_lvLanguages.Columns.Add(KPRes.File); KPTranslation trlEng = new KPTranslation(); trlEng.Properties.NameEnglish = "English"; trlEng.Properties.NameNative = "English"; trlEng.Properties.ApplicationVersion = PwDefs.VersionString; trlEng.Properties.AuthorName = AppDefs.DefaultTrlAuthor; trlEng.Properties.AuthorContact = AppDefs.DefaultTrlContact; string strDirA = AceApplication.GetLanguagesDir(AceDir.App, false); string strDirASep = UrlUtil.EnsureTerminatingSeparator(strDirA, false); string strDirU = AceApplication.GetLanguagesDir(AceDir.User, false); List <KeyValuePair <string, KPTranslation> > lTrls = new List <KeyValuePair <string, KPTranslation> >(); lTrls.Add(new KeyValuePair <string, KPTranslation>(string.Empty, trlEng)); AddTranslations(strDirA, lTrls); if (WinUtil.IsAppX) { AddTranslations(strDirU, lTrls); } lTrls.Sort(LanguageForm.CompareTrlItems); foreach (KeyValuePair <string, KPTranslation> kvp in lTrls) { KPTranslationProperties p = kvp.Value.Properties; string strName = p.NameEnglish + " (" + p.NameNative + ")"; string strVer = PwDefs.GetTranslationDisplayVersion(p.ApplicationVersion); bool bBuiltIn = ((kvp.Key.Length == 0) || (WinUtil.IsAppX && kvp.Key.StartsWith(strDirASep, StrUtil.CaseIgnoreCmp))); ListViewItem lvi = m_lvLanguages.Items.Add(strName, 0); lvi.SubItems.Add(strVer); lvi.SubItems.Add(p.AuthorName); lvi.SubItems.Add(p.AuthorContact); lvi.SubItems.Add(bBuiltIn ? KPRes.BuiltInU : kvp.Key); lvi.Tag = kvp.Key; // try // { // string nl = MessageService.NewLine; // lvi.ToolTipText = strName + " " + strVer + nl + p.AuthorName + // nl + p.AuthorContact + nl + nl + kvp.Key; // } // catch(Exception) { Debug.Assert(false); } // Too long? // if(kvp.Key.Equals(Program.Config.Application.GetLanguageFilePath(), // StrUtil.CaseIgnoreCmp)) // UIUtil.SetFocusedItem(m_lvLanguages, lvi, true); } UIUtil.ResizeColumns(m_lvLanguages, new int[] { 5, 2, 5, 5, 3 }, true); UIUtil.SetFocus(m_lvLanguages, this); }