private void ProcessDias(string _periodo) { string Periodo = _periodo; Regex regex_datas = new Regex(@"\d+"); var datas = regex_datas.Matches(Periodo); int dia_inicial = int.Parse(datas[0].ToString()); int mes_inicial = int.Parse(datas[1].ToString()); DateTime inicio = new DateTime(DateTime.Today.Year, mes_inicial, dia_inicial); for (int i = 0; i < 7; i++) { Dia dia = new Dia(inicio.AddDays(i)); Semana.Add(dia); } }
private void ProcessPratos(string _info) { string Info = _info; Regex desjejum = new Regex(@"DESJEJUM", RegexOptions.IgnoreCase); Regex almoco = new Regex(@"ALMOÇO", RegexOptions.IgnoreCase); Regex jantar = new Regex(@"JANTAR", RegexOptions.IgnoreCase); Regex prato = new Regex(@"^(-\s?)?(?<prato>([A-Za-z&;/\'\(\)]+\s?)+)", RegexOptions.IgnoreCase); Regex regex_data = new Regex(@"\d+\/\d+\/\d+"); int dia = -1; StringBuilder sb_desjejum = new StringBuilder(); StringBuilder sb_almoco = new StringBuilder(); StringBuilder sb_jantar = new StringBuilder(); StringBuilder sb_atual = null; DateTime data = new DateTime(); var lines = Info.Split(new string[] { Environment.NewLine, "<br>" }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (regex_data.IsMatch(line)) { if (dia >= 0) { var new_day = new Dia(data); new_day.Desjejum = sb_desjejum.ToString(); sb_desjejum = new StringBuilder(); new_day.Almoco = sb_almoco.ToString(); sb_almoco = new StringBuilder(); new_day.Jantar = sb_jantar.ToString(); sb_jantar = new StringBuilder(); Semana.Add(new_day); } dia++; data = DateTime.Parse(regex_data.Matches(line)[0].ToString()); if (6 < dia) break; } if (desjejum.IsMatch(line)) { sb_atual = sb_desjejum; } else if (almoco.IsMatch(line)) { sb_atual = sb_almoco; } else if (jantar.IsMatch(line)) { sb_atual = sb_jantar; } else { string linha_prato = prato.Match(line).Groups["prato"].ToString(); if (!String.IsNullOrWhiteSpace(linha_prato)) { ReplaceHTML(ref linha_prato); sb_atual.AppendLine(linha_prato); } } } //Semana[dia].Desjejum = sb_desjejum.ToString(); //Semana[dia].Almoco = sb_almoco.ToString(); //Semana[dia].Jantar = sb_jantar.ToString(); }
private void ProcessPratos(string _info) { string Info = _info; Regex desjejum = new Regex(@"DESJEJUM", RegexOptions.IgnoreCase); Regex almoco = new Regex(@"ALMOÇO", RegexOptions.IgnoreCase); Regex jantar = new Regex(@"JANTAR", RegexOptions.IgnoreCase); Regex prato = new Regex(@"^(-\s?)?(?<prato>([A-Za-z&;/\'\(\)]+\s?)+)", RegexOptions.IgnoreCase); Regex regex_data = new Regex(@"\d+\/\d+\/\d+"); int dia = -1; StringBuilder sb_desjejum = new StringBuilder(); StringBuilder sb_almoco = new StringBuilder(); StringBuilder sb_jantar = new StringBuilder(); StringBuilder sb_atual = null; DateTime data = new DateTime(); var lines = Info.Split(new string[] { Environment.NewLine, "<br>" }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (regex_data.IsMatch(line)) { if (dia >= 0) { var new_day = new Dia(data); new_day.Desjejum = sb_desjejum.ToString(); sb_desjejum = new StringBuilder(); new_day.Almoco = sb_almoco.ToString(); sb_almoco = new StringBuilder(); new_day.Jantar = sb_jantar.ToString(); sb_jantar = new StringBuilder(); Semana.Add(new_day); } dia++; data = DateTime.Parse(regex_data.Matches(line)[0].ToString()); if (6 < dia) { break; } } if (desjejum.IsMatch(line)) { sb_atual = sb_desjejum; } else if (almoco.IsMatch(line)) { sb_atual = sb_almoco; } else if (jantar.IsMatch(line)) { sb_atual = sb_jantar; } else { string linha_prato = prato.Match(line).Groups["prato"].ToString(); if (!String.IsNullOrWhiteSpace(linha_prato)) { ReplaceHTML(ref linha_prato); sb_atual.AppendLine(linha_prato); } } } //Semana[dia].Desjejum = sb_desjejum.ToString(); //Semana[dia].Almoco = sb_almoco.ToString(); //Semana[dia].Jantar = sb_jantar.ToString(); }
internal void LoadInfo() { ProcessHelper ph = new ProcessHelper(); ph.ProcessInfo(wupdater.Info, wupdater.Periodo); pivot.Items.Clear(); foreach (var Dia in ph.Semana) { PivotItem aba = new PivotItem { Header = Dia.NomeDoDia() }; ScrollViewer sv_dia = new ScrollViewer(); StackPanel stack_refeicoes = new StackPanel(); sv_dia.Content = stack_refeicoes; TextBlock data = new TextBlock { Text = string.Format("Dia {0}/{1}", Dia.Data.Day, Dia.Data.Month) }; stack_refeicoes.Children.Add(data); if (!String.IsNullOrEmpty(Dia.Desjejum)) { AdicionaRefeicao(Dia, stack_refeicoes, Refeicao.Desjejum); } if (!String.IsNullOrEmpty(Dia.Almoco)) { AdicionaRefeicao(Dia, stack_refeicoes, Refeicao.Almoço); } if (!String.IsNullOrEmpty(Dia.Jantar)) { AdicionaRefeicao(Dia, stack_refeicoes, Refeicao.Jantar); } sv_dia.Style = (Style)App.Current.Resources["AbaDiaDaSemana"]; aba.Content = sv_dia; pivot.Items.Add(aba); if (Dia.Data.DayOfWeek == DateTime.Today.DayOfWeek) { pivot.SelectedItem = aba; AdControl ad = new AdControl("74e1a034-5680-4210-808c-52463e8bbcf1", "162701", true) { IsAutoCollapseEnabled = true, Margin = new Thickness(12), Width = 300, Height = 50 }; #if DEBUG ad.ErrorOccurred += ad_ErrorOccurred; #endif stack_refeicoes.Children.Add(ad); } } }