public meusInstitutos() { InitializeComponent(); loadInfo(); foreach (int instituto_id in currentUser.user_institutos_id) { foreach (InstitutoInfo i in listaInstiutos) { if (instituto_id == i.id) { Grid novaGrid = new Grid(); novaGrid.Height = 80; ColumnDefinition colDef0 = new ColumnDefinition(); colDef0.Width = new GridLength(50, GridUnitType.Star); ColumnDefinition colDef1 = new ColumnDefinition(); colDef1.Width = new GridLength(225, GridUnitType.Star); ColumnDefinition colDef2 = new ColumnDefinition(); colDef2.Width = new GridLength(100, GridUnitType.Star); novaGrid.ColumnDefinitions.Add(colDef0); novaGrid.ColumnDefinitions.Add(colDef1); novaGrid.ColumnDefinitions.Add(colDef2); TextBlock newTextBox = new TextBlock(); newTextBox.Text = i.nome; newTextBox.HorizontalAlignment = HorizontalAlignment.Left; newTextBox.VerticalAlignment = VerticalAlignment.Top; newTextBox.FontSize = 20; newTextBox.Margin = new Thickness(25, 25, 0, 0); newTextBox.SetValue(Grid.ColumnProperty, 1); nova2 botao = new nova2(); botao.SetValue(Grid.ColumnProperty, 0); botao.VerticalAlignment = VerticalAlignment.Top; botao.HorizontalAlignment = HorizontalAlignment.Right; botao.Margin = new Thickness(0, 8, 0, 0); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FF60C4E5"); botao.Background = brush; StackPanel stackpanel = new StackPanel(); stackpanel.Orientation = Orientation.Horizontal; var icon = new nova { Kind = PackIconKind.Edit }; var b1 = (Brush)converter.ConvertFromString("White"); icon.Name = "Edit" + i.id; icon.Width = 25; icon.Height = 25; icon.PreviewMouseLeftButtonDown += EditIcon_PreviewMouseLeftButtonDown; icon.Foreground = b1; stackpanel.Children.Add(icon); botao.Content = stackpanel; botao.Name = "Edit" + i.id; botao.PreviewMouseLeftButtonDown += EditIcon_PreviewMouseLeftButtonDown; nova2 botao2 = new nova2(); botao2.SetValue(Grid.ColumnProperty, 0); botao2.VerticalAlignment = VerticalAlignment.Bottom; botao2.HorizontalAlignment = HorizontalAlignment.Right; botao2.Margin = new Thickness(0, 0, 0, 3); botao2.Background = brush; StackPanel stackpanel2 = new StackPanel(); stackpanel2.Orientation = Orientation.Horizontal; var icon2 = new nova { Kind = PackIconKind.Delete }; icon2.Width = 25; icon2.Height = 25; icon2.PreviewMouseLeftButtonDown += BinIcon_PreviewMouseLeftButtonDown; icon2.Name = "Delete" + Convert.ToString(i.id); icon2.Foreground = b1; stackpanel2.Children.Add(icon2); botao2.Content = stackpanel2; botao2.Name = "Delete" + Convert.ToString(i.id); botao2.PreviewMouseLeftButtonDown += BinIcon_PreviewMouseLeftButtonDown; Grid novaGrid2 = new Grid(); novaGrid2.SetValue(Grid.ColumnProperty, 2); novaGrid2.Width = 35; novaGrid2.Height = 32; novaGrid2.VerticalAlignment = VerticalAlignment.Center; novaGrid2.HorizontalAlignment = HorizontalAlignment.Center; Label label = new Label(); label.FontSize = 18; label.Margin = new Thickness(-25, 0, 0, -6); label.Content = i.rating; var icon3 = new nova { Kind = PackIconKind.Star }; icon3.Width = 30; icon3.Height = 28; icon3.Margin = new Thickness(24, 2, -19, 2); var brush2 = (Brush)converter.ConvertFromString("#FFFFD700"); icon3.Foreground = brush2; novaGrid2.Children.Add(label); novaGrid2.Children.Add(icon3); painel.Children.Add(novaGrid); novaGrid.Children.Add(newTextBox); novaGrid.Children.Add(botao); novaGrid.Children.Add(botao2); novaGrid.Children.Add(novaGrid2); } } } }
private void Button_Click(object sender, RoutedEventArgs e2) { painel.Children.Clear(); tabelatop_filtro.Visibility = Visibility.Collapsed; LoginPage logPage = new LoginPage(); currentUser = logPage.getCurrentUser(); bool valido = true; string nomeservico; try { nomeservico = tiposervico.SelectedItem.ToString(); } catch { nomeservico = ""; } string localizacao = localizacaoBox.Text; double precomin = 0; if (!(minpreco.Text == "")) { try { precomin = Convert.ToDouble(minpreco.Text); } catch { MessageBox.Show("Please provide valid price input value (Number)!"); valido = false; } } double precomax = 999999; if (!(maxpreco.Text == "")) { try { precomax = Convert.ToDouble(maxpreco.Text); } catch { MessageBox.Show("Please provide valid price input value (Number)!"); valido = false; } } double precoservico = -1; loadInfo(); foreach (ServiceInfo s in listaServicos) { valido = true; try { precoservico = Convert.ToDouble(s.preco); } catch { valido = false; } if (valido == true) { if ((s.tipo.Equals(nomeservico) || nomeservico.Equals("")) && precomin <= precoservico && precoservico <= precomax) { foreach (InstitutoInfo i in listaInstitutos) { if (i.id == s.instituto_id && i.localizacao.StartsWith(localizacao)) { Grid novaGrid = new Grid(); novaGrid.Height = 40; ColumnDefinition colDef0 = new ColumnDefinition(); colDef0.Width = new GridLength(15, GridUnitType.Star); ColumnDefinition colDef1 = new ColumnDefinition(); colDef1.Width = new GridLength(30, GridUnitType.Star); ColumnDefinition colDef2 = new ColumnDefinition(); colDef2.Width = new GridLength(160, GridUnitType.Star); ColumnDefinition colDef3 = new ColumnDefinition(); colDef3.Width = new GridLength(85, GridUnitType.Star); ColumnDefinition colDef4 = new ColumnDefinition(); colDef4.Width = new GridLength(50, GridUnitType.Star); novaGrid.ColumnDefinitions.Add(colDef0); novaGrid.ColumnDefinitions.Add(colDef1); novaGrid.ColumnDefinitions.Add(colDef2); novaGrid.ColumnDefinitions.Add(colDef3); novaGrid.ColumnDefinitions.Add(colDef4); var icon = new nova { Kind = PackIconKind.StarBorder }; foreach (int l in currentUser.favoritos) { if (l == s.id) { icon = new nova { Kind = PackIconKind.Star }; } } icon.Width = 30; icon.Height = 45; icon.HorizontalAlignment = HorizontalAlignment.Center; icon.SetValue(Grid.ColumnProperty, 1); icon.Name = "seta" + s.id; icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; nova2 novo = new nova2(); novo.SetValue(Grid.ColumnProperty, 1); novo.Width = 30; novo.Height = 45; novo.Opacity = 0; novaGrid.Children.Add(novo); novo.Name = "seta" + s.id; novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; TextBlock newTextBox = new TextBlock(); newTextBox.Text = s.tipo; newTextBox.VerticalAlignment = VerticalAlignment.Center; newTextBox.Margin = new Thickness(10, 10, 0, 0); newTextBox.FontSize = 18; newTextBox.SetValue(Grid.ColumnProperty, 2); TextBlock newTextBox2 = new TextBlock(); newTextBox2.Text = s.preco + " €"; newTextBox2.FontSize = 18; newTextBox2.Margin = new Thickness(10, 10, 0, 0); newTextBox2.VerticalAlignment = VerticalAlignment.Center; newTextBox2.SetValue(Grid.ColumnProperty, 3); var icon2 = new nova { Kind = PackIconKind.ArrowRight }; icon2.Width = 25; icon2.Height = 25; icon2.VerticalAlignment = VerticalAlignment.Center; icon2.HorizontalAlignment = HorizontalAlignment.Left; icon2.SetValue(Grid.ColumnProperty, 4); icon2.Name = "seta" + s.id; icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown; painel.Children.Add(novaGrid); novaGrid.Children.Add(newTextBox); novaGrid.Children.Add(newTextBox2); novaGrid.Children.Add(icon); novaGrid.Children.Add(icon2); } } } } } filtros.Visibility = Visibility.Collapsed; scrollViewer.Margin = new Thickness(0, 0, 10, 44); minpreco.Text = ""; maxpreco.Text = ""; localizacaoBox.Text = ""; tiposervico.SelectedIndex = -1; }
private void FavIcon_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Console.WriteLine(sender); int id = Convert.ToInt32(sender.ToString().Replace("seta", "")); LoginPage logPage = new LoginPage(); currentUser = logPage.getCurrentUser(); List <String> novoConteudoFicheiro = new List <String>(); RegisterPage registerpageobject = new RegisterPage(); List <UtilizadorInfo> utilizadores = registerpageobject.readRegisto(); bool adicionar = true; foreach (UtilizadorInfo u in utilizadores) { if (u.id == currentUser.id) { foreach (int i in u.favoritos) { if (i == id) { adicionar = false; } } if (adicionar == true) { u.favoritos.Add(id); } else { u.favoritos.Remove(id); } } string conteudo = u.id + "-" + u.tipoConta + "-" + u.email + "-" + u.username + "-" + u.password + "-" + u.localidade + "-" + u.foto + "-{"; foreach (int i in u.favoritos) { conteudo = conteudo + i + ","; } conteudo = conteudo + "}-{"; foreach (string s in u.reservas) { conteudo = conteudo + s + ","; } conteudo = conteudo + "}-{"; foreach (int i in u.user_institutos_id) { conteudo = conteudo + i + ","; } conteudo = conteudo + "}"; novoConteudoFicheiro.Add(conteudo); } registarAlteracoes(novoConteudoFicheiro); currentUser = logPage.getCurrentUser(); painel.Children.Clear(); bool valido = true; string nomeservico; try { nomeservico = tiposervico.SelectedItem.ToString(); } catch { nomeservico = ""; } string localizacao = localizacaoBox.Text; double precomin = 0; if (!(minpreco.Text == "")) { try { precomin = Convert.ToDouble(minpreco.Text); } catch { valido = false; } } double precomax = 999999; if (!(maxpreco.Text == "")) { try { precomax = Convert.ToDouble(maxpreco.Text); } catch { valido = false; } } double precoservico = -1; loadInfo(); foreach (ServiceInfo s in listaServicos) { try { precoservico = Convert.ToDouble(s.preco); } catch { valido = false; } if (valido == true) { if ((s.tipo.Equals(nomeservico) || nomeservico.Equals("")) && precomin <= precoservico && precoservico <= precomax) { foreach (InstitutoInfo i in listaInstitutos) { if (i.id == s.instituto_id && i.localizacao.StartsWith(localizacao)) { Grid novaGrid = new Grid(); novaGrid.Height = 40; ColumnDefinition colDef0 = new ColumnDefinition(); colDef0.Width = new GridLength(15, GridUnitType.Star); ColumnDefinition colDef1 = new ColumnDefinition(); colDef1.Width = new GridLength(30, GridUnitType.Star); ColumnDefinition colDef2 = new ColumnDefinition(); colDef2.Width = new GridLength(160, GridUnitType.Star); ColumnDefinition colDef3 = new ColumnDefinition(); colDef3.Width = new GridLength(85, GridUnitType.Star); ColumnDefinition colDef4 = new ColumnDefinition(); colDef4.Width = new GridLength(50, GridUnitType.Star); novaGrid.ColumnDefinitions.Add(colDef0); novaGrid.ColumnDefinitions.Add(colDef1); novaGrid.ColumnDefinitions.Add(colDef2); novaGrid.ColumnDefinitions.Add(colDef3); novaGrid.ColumnDefinitions.Add(colDef4); var icon = new nova { Kind = PackIconKind.StarBorder }; foreach (int l in currentUser.favoritos) { if (l == s.id) { icon = new nova { Kind = PackIconKind.Star }; } } icon.Width = 30; icon.Height = 45; icon.HorizontalAlignment = HorizontalAlignment.Center; icon.SetValue(Grid.ColumnProperty, 1); icon.Name = "seta" + s.id; icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; nova2 novo = new nova2(); novo.SetValue(Grid.ColumnProperty, 1); novo.Width = 30; novo.Height = 45; novo.Opacity = 0; novaGrid.Children.Add(novo); novo.Name = "seta" + s.id; novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; TextBlock newTextBox = new TextBlock(); newTextBox.Text = s.tipo; newTextBox.VerticalAlignment = VerticalAlignment.Center; newTextBox.Margin = new Thickness(10, 10, 0, 0); newTextBox.FontSize = 18; newTextBox.SetValue(Grid.ColumnProperty, 2); TextBlock newTextBox2 = new TextBlock(); newTextBox2.Text = s.preco + " €"; newTextBox2.FontSize = 18; newTextBox2.Margin = new Thickness(10, 10, 0, 0); newTextBox2.VerticalAlignment = VerticalAlignment.Center; newTextBox2.SetValue(Grid.ColumnProperty, 3); var icon2 = new nova { Kind = PackIconKind.ArrowRight }; icon2.Width = 25; icon2.Height = 25; icon2.VerticalAlignment = VerticalAlignment.Center; icon2.HorizontalAlignment = HorizontalAlignment.Left; icon2.SetValue(Grid.ColumnProperty, 4); icon2.Name = "seta" + s.id; icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown; painel.Children.Add(novaGrid); novaGrid.Children.Add(newTextBox); novaGrid.Children.Add(newTextBox2); novaGrid.Children.Add(icon); novaGrid.Children.Add(icon2); } } } } } }
public servicossearch() { InitializeComponent(); this.loadInfo(); LoginPage logPage = new LoginPage(); currentUser = logPage.getCurrentUser(); foreach (ServiceInfo s in listaServicos) { Grid novaGrid = new Grid(); novaGrid.Height = 40; ColumnDefinition colDef0 = new ColumnDefinition(); colDef0.Width = new GridLength(15, GridUnitType.Star); ColumnDefinition colDef1 = new ColumnDefinition(); colDef1.Width = new GridLength(30, GridUnitType.Star); ColumnDefinition colDef2 = new ColumnDefinition(); colDef2.Width = new GridLength(160, GridUnitType.Star); ColumnDefinition colDef3 = new ColumnDefinition(); colDef3.Width = new GridLength(85, GridUnitType.Star); ColumnDefinition colDef4 = new ColumnDefinition(); colDef4.Width = new GridLength(50, GridUnitType.Star); novaGrid.ColumnDefinitions.Add(colDef0); novaGrid.ColumnDefinitions.Add(colDef1); novaGrid.ColumnDefinitions.Add(colDef2); novaGrid.ColumnDefinitions.Add(colDef3); novaGrid.ColumnDefinitions.Add(colDef4); var icon = new nova { Kind = PackIconKind.StarBorder }; foreach (int i in currentUser.favoritos) { if (i == s.id) { icon = new nova { Kind = PackIconKind.Star }; } } icon.Width = 30; icon.Height = 45; icon.SetValue(Grid.ColumnProperty, 1); icon.Name = "seta" + s.id; icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; nova2 novo = new nova2(); novo.SetValue(Grid.ColumnProperty, 1); novo.Width = 30; novo.Height = 45; novo.Opacity = 0; novaGrid.Children.Add(novo); novo.Name = "seta" + s.id; novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; TextBlock newTextBox = new TextBlock(); newTextBox.Text = s.tipo; newTextBox.VerticalAlignment = VerticalAlignment.Center; newTextBox.FontSize = 18; newTextBox.Margin = new Thickness(10, 10, 0, 0); newTextBox.SetValue(Grid.ColumnProperty, 2); TextBlock newTextBox2 = new TextBlock(); newTextBox2.Text = s.preco + " €"; newTextBox2.FontSize = 18; newTextBox2.Margin = new Thickness(10, 10, 0, 0); newTextBox2.VerticalAlignment = VerticalAlignment.Center; newTextBox2.SetValue(Grid.ColumnProperty, 3); var icon2 = new nova { Kind = PackIconKind.ArrowRight }; icon2.Width = 25; icon2.Height = 25; icon2.VerticalAlignment = VerticalAlignment.Center; icon2.HorizontalAlignment = HorizontalAlignment.Left; icon2.SetValue(Grid.ColumnProperty, 4); icon2.Name = "seta" + s.id; icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown; painel.Children.Add(novaGrid); novaGrid.Children.Add(newTextBox); novaGrid.Children.Add(newTextBox2); novaGrid.Children.Add(icon); novaGrid.Children.Add(icon2); } }
public institutoPage(int id, Page paginaanterior) { if (id == -1) { return; } InitializeComponent(); paginaAnterior = paginaanterior; Console.WriteLine(paginaAnterior); List<InstitutoInfo> institutos = readInstituto(); foreach (InstitutoInfo i in institutos) { if (i.id == id) { currentInstituto = i; } } nomeInstituto.Content = currentInstituto.nome; rating.Content = currentInstituto.rating; descricaoServico.Document.Blocks.Clear(); descricaoServico.Document.Blocks.Add(new Paragraph(new Run(currentInstituto.descricao)) { FontSize = 18 }); if (currentInstituto.foto != "null") { ImageBrush myBrush = new ImageBrush(); Image image = new Image(); image.Source = new BitmapImage( new Uri( BaseUriHelper.GetBaseUri(this), currentInstituto.foto)); myBrush.ImageSource = image.Source; userfotogrid.Background = myBrush; } int flag = 0; LoginPage logPage = new LoginPage(); currentUser = logPage.getCurrentUser(); foreach (int service_id in currentInstituto.servicos_id) { servicePage ServicePage = new servicePage(service_id,paginaAnterior); ServiceInfo servico = ServicePage.getCurrentService(); Grid novaGrid = new Grid(); novaGrid.Height = 40; ColumnDefinition colDef0 = new ColumnDefinition(); colDef0.Width = new GridLength(15, GridUnitType.Star); ColumnDefinition colDef1 = new ColumnDefinition(); colDef1.Width = new GridLength(30, GridUnitType.Star); ColumnDefinition colDef2 = new ColumnDefinition(); colDef2.Width = new GridLength(160, GridUnitType.Star); ColumnDefinition colDef3 = new ColumnDefinition(); colDef3.Width = new GridLength(85, GridUnitType.Star); ColumnDefinition colDef4 = new ColumnDefinition(); colDef4.Width = new GridLength(50, GridUnitType.Star); novaGrid.ColumnDefinitions.Add(colDef0); novaGrid.ColumnDefinitions.Add(colDef1); novaGrid.ColumnDefinitions.Add(colDef2); novaGrid.ColumnDefinitions.Add(colDef3); novaGrid.ColumnDefinitions.Add(colDef4); var icon = new nova { Kind = PackIconKind.StarBorder }; foreach (int i in currentUser.favoritos) { if (i == service_id) { icon = new nova { Kind = PackIconKind.Star }; } } icon.Width = 30; icon.Height = 45; icon.SetValue(Grid.ColumnProperty, 1); icon.Name = "seta" + service_id; icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; nova2 novo = new nova2(); novo.SetValue(Grid.ColumnProperty, 1); novo.Width = 30; novo.Height = 45; novo.Opacity = 0; novaGrid.Children.Add(novo); novo.Name = "seta" + service_id; novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown; TextBlock newTextBox = new TextBlock(); newTextBox.Text = servico.tipo; newTextBox.VerticalAlignment = VerticalAlignment.Center; newTextBox.FontSize = 18; newTextBox.Margin = new Thickness(10, 10, 0, 0); newTextBox.SetValue(Grid.ColumnProperty, 2); TextBlock newTextBox2 = new TextBlock(); newTextBox2.Text = servico.preco + " €"; newTextBox2.FontSize = 18; newTextBox2.Margin = new Thickness(10, 10, 0, 0); newTextBox2.VerticalAlignment = VerticalAlignment.Center; newTextBox2.SetValue(Grid.ColumnProperty, 3); var icon2 = new nova { Kind = PackIconKind.ArrowRight }; icon2.Width = 25; icon2.Height = 25; icon2.VerticalAlignment = VerticalAlignment.Center; icon2.HorizontalAlignment = HorizontalAlignment.Left; icon2.SetValue(Grid.ColumnProperty, 4); icon2.Name = "seta" + service_id; icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown; painel.Children.Add(novaGrid); novaGrid.Children.Add(newTextBox); novaGrid.Children.Add(newTextBox2); novaGrid.Children.Add(icon); novaGrid.Children.Add(icon2); if (flag % 2 == 0) { var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFD0EDED"); novaGrid.Background = brush; } else { var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFC2DCDC"); novaGrid.Background = brush; } flag++; } Console.WriteLine(paginaAnterior); }