//--------------------------------------------------------------------------------------------- // lstFamilyName の選択の変更に伴って、lstTypeface を更新する 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.DFont.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); } lstTypeface.ItemsSource = list; //------------------------------------------------------- // 初期値を設定する if (lstTypeface.Items.Count > 0) { var style = new TypefaceStyle(FFont.FontStyle, FFont.FontStretch, FFont.FontWeight); int index = 0; for (index = 0; index < lstTypeface.Items.Count; ++index) { TextBlock item = lstTypeface.Items[index] as TextBlock; if (style.Equals((TypefaceStyle)item.Tag)) { break; } } if (index == lstTypeface.Items.Count) { index = 0; } lstTypeface.SelectedIndex = index; txtTypeface.Text = ((TextBlock)lstTypeface.SelectedItem).Text; lstTypeface.ScrollIntoView(lstTypeface.Items[index]); } }
//--------------------------------------------------------------------------------------------- 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); }