リスト用のフォント
Ejemplo n.º 1
0
        //---------------------------------------------------------------------------------------------
        // cmbLanguage の選択に伴って、lstFamilyName を更新する
        private void UpdateFamilyName()
        {
            var list = new List<ListedFontViewModel>();

            int fontIndex = 0;
            // すべての言語のとき
            if (DlgLanguage == null)
            {
                foreach (FontFamily family in Fonts.SystemFontFamilies)
                {
                    LanguageSpecificStringDictionary dic1 = family.FamilyNames;

                    foreach (XmlLanguage lang in dic1.Keys)
                    {
                        ListedFontViewModel item1 = new ListedFontViewModel();

                        string s = dic1[lang] as string;

                        if ((s != null) && (s.Length > 0))
                        {
                            item1.FontName = s;
                            item1.FontFamily = family;
                            item1.SampleString = "Getting Comfortable with Aow";

                            list.Add(item1);
                        }
                    }
                }
            }
            else // 特定の言語のとき
            {
                foreach (FontFamily family in Fonts.SystemFontFamilies)
                {
                    LanguageSpecificStringDictionary dic2 = family.FamilyNames;
                    ListedFontViewModel item2 = new ListedFontViewModel();

                    string s = "";

                    if (dic2.ContainsKey(FXmlLanguage))
                    {
                        s = dic2[FXmlLanguage] as string;

                        if ((s != null) && (s.Length > 0))
                        {
                            item2.FontName = s;
                            item2.FontFamily = family;
                            item2.SampleString = "Kappaと発音してください。";

                            list.Add(item2);
                        }
                    }
                }
            }

            list.Sort(SortComparison);

            fontIndex = Math.Max(list.FindIndex(t => (t.FontFamily as FontFamily).Equals(FFontFamily)), 0);

            lstFamilyName.ItemsSource = list;

            lstFamilyName.SelectedIndex = fontIndex;
            txtFamilyName.Text = ((string)list[fontIndex].FontName).ToString();

            lstFamilyName.ScrollIntoView(lstFamilyName.SelectedItem);
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------------------------------
        // 昇順ソートのためのコールバック関数
        private int SortComparison(ListedFontViewModel item1, ListedFontViewModel item2)
        {
            string s1 = item1.FontName as string;
            string s2 = item2.FontName as string;

            return s1.CompareTo(s2);
        }