コード例 #1
0
        //---------------------------------------------------------------------------------------------
        // FirstFamilyName の選択の変更に伴って、FirstTypeface を更新する
        private void UpdateTypeFace()
        {
            var list   = new List <TextBlock>();
            var family = new FontFamily(txtFamilyName.Text);

            foreach (Typeface face in family.GetTypefaces())
            {
                TextBlock item = new TextBlock();

                foreach (KeyValuePair <XmlLanguage, string> dic in face.FaceNames)
                {
                    if (dic.Key.IetfLanguageTag == this.Font.FontLanguage)
                    {
                        // シミュレートするフォントのとき
                        if ((face.IsBoldSimulated) || (face.IsObliqueSimulated))
                        {
                            item.Text = String.Format("{0} (simulated)", dic.Value);
                        }
                        else
                        {
                            item.Text = String.Format("{0}", dic.Value);
                        }
                    }
                }

                item.Tag = new TypefaceStyle(face.Style, face.Stretch, face.Weight);

                list.Add(item);
            }

            FirstTypeface.ItemsSource = list;

            //-------------------------------------------------------
            // 初期値を設定する
            if (FirstTypeface.Items.Count > 0)
            {
                var style = new TypefaceStyle(FFont.FontStyle, FFont.FontStretch, FFont.FontWeight);

                int index = 0;
                for (index = 0; index < FirstTypeface.Items.Count; ++index)
                {
                    TextBlock item = FirstTypeface.Items[index] as TextBlock;

                    if (style.Equals((TypefaceStyle)item.Tag))
                    {
                        break;
                    }
                }

                if (index == FirstTypeface.Items.Count)
                {
                    index = 0;
                }

                FirstTypeface.SelectedIndex = index;
                txtTypeface.Text            = ((TextBlock)FirstTypeface.SelectedItem).Text;
                FirstTypeface.ScrollIntoView(FirstTypeface.Items[index]);
            }
        }
コード例 #2
0
        //---------------------------------------------------------------------------------------------
        public override bool Equals(object obj)
        {
            TypefaceStyle style = obj as TypefaceStyle;
            bool          check = false;

            if (FFontStyle.Equals(style.FontStyle) && (FFontStretch.Equals(style.FontStretch)) && (FFontWeight.Equals(style.FontWeight)))
            {
                check = true;
            }

            return(check);
        }