public AddAccountUserControl(MainUserControl main) { _dic = new List<MyKeyValuePair<string, string>>(); _listAccounts = new ObservableCollection<string>(); main.MyListView.ItemsSource = _listAccounts; InitializeComponent(); try { using (FileStream stream = new FileStream(FILE, FileMode.OpenOrCreate)) { TextReader reader = new StreamReader(stream); XmlSerializer serializer = new XmlSerializer(typeof(List<MyKeyValuePair<string, string>>)); _dic = serializer.Deserialize(reader) as List<MyKeyValuePair<string, string>>; foreach (MyKeyValuePair<string, string> cur in _dic) { Console.WriteLine("Email=" + cur.Key + " Secret=" + cur.Value); _listAccounts.Add(cur.Key); } } } catch (Exception) { File.Delete(FILE); } }
public AddAccountUserControl(MainUserControl main) { _dic = new List <MyKeyValuePair <string, string> >(); _listAccounts = new ObservableCollection <string>(); main.MyListView.ItemsSource = _listAccounts; InitializeComponent(); try { using (FileStream stream = new FileStream(FILE, FileMode.OpenOrCreate)) { TextReader reader = new StreamReader(stream); XmlSerializer serializer = new XmlSerializer(typeof(List <MyKeyValuePair <string, string> >)); _dic = serializer.Deserialize(reader) as List <MyKeyValuePair <string, string> >; foreach (MyKeyValuePair <string, string> cur in _dic) { Console.WriteLine("Email=" + cur.Key + " Secret=" + cur.Value); _listAccounts.Add(cur.Key); } } } catch (Exception) { File.Delete(FILE); } }
public MainWindow() { _main = new MainUserControl(); _account = new AddAccountUserControl(_main); _main.LoadAccount(_account); InitializeComponent(); ContentControl.Content = _main; }