/// <summary> /// Refreshes A ComboBox's Source /// </summary> /// <param name="cb">The ComboBox To Refresh</param> /// <param name="bs">The Source Of The ComboBox</param> private void RefereshComboBox(ComboBox cb, BaseSingleton bs) { cb.ItemsSource = bs.AllObjects(); ICollectionView view = CollectionViewSource.GetDefaultView(cb.ItemsSource); view.Refresh(); }
/// <summary> /// Refreshes The List View /// </summary> /// <param name="bs"></param> protected void RefreshListView(BaseSingleton bs) { BaseListWindow.listviewCurrent.ItemsSource = bs.AllObjects(); ICollectionView view = CollectionViewSource.GetDefaultView(BaseListWindow.listviewCurrent.ItemsSource); view.Refresh(); }
/// <summary> /// Loads A Singleton's Object Data /// </summary> /// <typeparam name="T">The Type Of Object Data</typeparam> /// <param name="bs">The Singleton To Save To</param> /// <param name="filename">The File To Load From</param> private void LoadSingletonObject <T>(BaseSingleton bs, string filename) { if (File.Exists(filename)) { string content = new StreamReader(filename).ReadToEnd(); string[] objs = content.Split('\n'); foreach (string obj in objs) { if (obj.Length > 0) { var b = JsonConvert.DeserializeObject <T>(obj); bs.AddObject(b as BaseInfo); } } } else { bs.InitObjectList(); SaveSingletonObject(bs.AllObjects(), filename); } }