2 using System.ComponentModel;
3 using System.Collections.ObjectModel;
4 using System.Collections.Generic;
5 using System.Runtime.CompilerServices;
7 namespace FooEditEngine
9 public interface ICompleteItem : INotifyPropertyChanged
17 public class CompleteWord : ICompleteItem
23 public CompleteWord(string w)
26 this.PropertyChanged += new PropertyChangedEventHandler((s,e)=>{});
34 get { return this._word; }
35 set { this._word = value; this.OnPropertyChanged(); }
39 /// プロパティが変更されたことを通知する
41 public void OnPropertyChanged([CallerMemberName] string name = "")
43 if (this.PropertyChanged != null)
44 this.PropertyChanged(this, new PropertyChangedEventArgs(name));
48 /// プロパティが変更されたことを通知する
50 public event PropertyChangedEventHandler PropertyChanged;
53 public sealed class CompleteCollection<T> : ObservableCollection<T> where T : ICompleteItem
55 public const string ShowMember = "word";
60 public CompleteCollection()
62 this.LongestItem = default(T);
74 public void AddRange(IEnumerable<T> collection)
76 foreach (T s in collection)
80 public new void Add(T s)
82 if (this.LongestItem == null)
84 if (s.word.Length > this.LongestItem.word.Length)
89 public new void Insert(int index, T s)
91 if (this.LongestItem == null)
93 if (s.word.Length > this.LongestItem.word.Length)
95 base.Insert(index, s);
98 public new void Clear()
100 this.LongestItem = default(T);