Ejemplo n.º 1
0
 public void NewExpression()
 {
     try
     {
         actualExpression = ProgramManager.NextExpression();
     }
     catch(ArgumentNullException)
     {
         NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
     }
     EnglishBlock.Text = actualExpression.Eng;
     if (ShowIta.IsChecked.Value)
         ItalianBlock.Text = actualExpression.Ita;
     else
         ItalianBlock.Text = "Per mostrare questa espressione, sposta l'interruttore a destra";
     RemainingBlock.Text = "Espressioni rimaste: " + ProgramManager.ExpressionsLeft;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Metodo che carica il file selezionato
        /// </summary>
        /// <param name="fileName"></param>
        static public async void LoadFile(string fileName, List<string> exprTypes)
        {
            Initialize();
            state = Status.BUSY;
            fileName = Windows.ApplicationModel.Package.Current.InstalledLocation.Path + @"\Files\" + fileName;
            StreamReader sr;
            if (File.Exists(fileName))
            {
                sr = new StreamReader(fileName);

                string actualList = "";
                string line;

                while ((line = await sr.ReadLineAsync()) != null)
                {
                    if (line == "")
                        continue;
                    if (line[0] == '=')
                    {
                        line = line.Remove(0, 1);
                        actualList = line;
                        continue;
                    }
                    if (!line.Contains(">"))
                        continue;
                    string[] parts = line.Split('>');
                    Espression expr = new Espression(parts[0], parts[1]);

                    switch (actualList)
                    {
                        case "Grammar":
                            Grammar.Add(expr);
                            break;
                        case "Idiomatic":
                            Idiomatic.Add(expr);
                            break;
                        case "Multiple":
                            Multiple.Add(expr);
                            break;
                        case "Paraphrasing":
                            Paraphrasing.Add(expr);
                            break;
                        case "Phrasal":
                            Phrasal.Add(expr);
                            break;
                        case "Verb":
                            Verb.Add(expr);
                            break;
                        case "Vocabulary":
                            Vocabulary.Add(expr);
                            break;
                        default:
                            break;
                    }
                }
                sr.Close();
            }
            LoadExpressions(exprTypes);
        }