void Read(object param, ExecutedRoutedEventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.InitialDirectory = Directory.GetCurrentDirectory(); of.Filter = "Text Files (.txt)|*.txt"; var res = of.ShowDialog(); if (res == DialogResult.OK) { Filename = of.SafeFileName; int cpt = 1; Phrases.Clear(); var lines = File.ReadAllLines(of.FileName, Encoding.GetEncoding(1252)); foreach (string l in lines) { if (l[0] != '-' && l != "") { Phrases.Add(l); _stack.Children.Add(new PhraseControl(cpt, l, parole, this)); cpt++; } } PhraseInProgress = Phrases[0]; PhraseId = 0; InProgress = true; } }
void Open(object param, ExecutedRoutedEventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.InitialDirectory = Directory.GetCurrentDirectory(); of.Filter = "Text Files (.txt)|*.txt"; var res = of.ShowDialog(); if (res == DialogResult.OK) { Filename = of.SafeFileName; int cpt = 0; Phrases.Clear(); var lines = File.ReadAllLines(of.FileName, Encoding.GetEncoding(1252)); foreach (string l in lines) { if (l[0] != '-' && l != "") { Phrases.Add(l); ((PhraseControl)_stack.Children[cpt]).SetPhrase(l); cpt++; } } } }