void saveToSettings() { var tmp = new List <AlphabetItemData>(); var tmp2 = new List <OutputOrder>(); if (Alphabets != null) { foreach (var item in Alphabets) { tmp.Add(item.Data); } } if (OutputOrder != null) { foreach (var item in OutputOrder) { tmp2.Add(item); } } Data data = new Data() { AlphabetData = tmp, OutputOrderData = tmp2 }; setting.Data = AlphabetSettings.SerializeData <Data>(data); }
public Alphabet() { settings = new AlphabetSettings(); alphabetPresentation = new AlphabetPresentation(settings); Presentation = this.alphabetPresentation; alphabetPresentation.AlphabetChanged += new EventHandler(alphabetPresentation_AlphabetChanged); }
void setting_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Data") { this.setting.PropertyChanged -= new PropertyChangedEventHandler(setting_PropertyChanged); timer.Stop(); var data = AlphabetSettings.DeserializeData <Data>(setting.Data); this.SetAlphabetItems(data.AlphabetData); this.SetOutputOrders(data.OutputOrderData); } }
public AlphabetPresentation(AlphabetSettings setting) { this.setting = setting; this.setting.PropertyChanged += new PropertyChangedEventHandler(setting_PropertyChanged); this.OutputOrderView = CollectionViewSource.GetDefaultView(OutputOrder) as ListCollectionView; OutputOrderView.CustomSort = new IndexSorter <OutputOrder>(OutputOrder, OutputOrderView); this.AlphabetCollectionView = CollectionViewSource.GetDefaultView(Alphabets) as ListCollectionView; AlphabetCollectionView.CustomSort = new IndexSorter <AlphabetItem>(Alphabets, AlphabetCollectionView); timer.Tick += delegate(object o, EventArgs args) { timer.Stop(); this.setting.PropertyChanged -= new PropertyChangedEventHandler(setting_PropertyChanged); this.SetAlphabetItems(setting.Default.AlphabetData); this.SetOutputOrders(setting.Default.OutputOrderData); }; timer.Start(); InitializeComponent(); }
public AlphabetSettings() { data = AlphabetSettings.SerializeData <Data>(Default); }