private void Adopt(object sender, RoutedEventArgs e)
        {
            Button     i  = (Button)sender;
            PackIcon   b  = (PackIcon)i.Content;
            StackPanel s  = (StackPanel)i.Parent;
            Grid       gr = (Grid)s.Parent;
            Image      u  = (Image)gr.Children[1];
            String     x  = u.Source.ToString();
            Label      r  = (Label)gr.Children[2];
            Label      n  = (Label)gr.Children[3];
            Label      y  = (Label)gr.Children[4];
            Label      g  = (Label)gr.Children[5];

            String Nome_Bicho = n.Content.ToString();
            String Idades     = y.Content.ToString();
            String Raca       = r.Content.ToString();
            String genero     = g.Content.ToString();


            if (flagAdo)
            {
                foreach (ANIMAL zzs in Container.animais)
                {
                    if (zzs.Nome == Nome_Bicho && zzs.Idade == Idades)
                    {
                        Container.adocoes.Add(zzs);

                        b.BeginInit();
                        b.Kind = PackIconKind.Star;
                        b.EndInit();
                        flagAdo = false;
                        new Adocoes();
                        break;
                    }
                }
            }
            else if (!flagAdo)
            {
                foreach (ANIMAL zzs in Container.animais)
                {
                    if (zzs.Nome == Nome_Bicho && zzs.Idade == Idades)
                    {
                        Container.adocoes.Remove(zzs);

                        b.BeginInit();
                        b.Kind = PackIconKind.StarOutline;
                        b.EndInit();
                        flagAdo = true;
                        new Adocoes();
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Fave(object sender, RoutedEventArgs e)
        {
            Button     i  = (Button)sender;
            PackIcon   b  = (PackIcon)i.Content;
            StackPanel s  = (StackPanel)i.Parent;
            Grid       gr = (Grid)s.Parent;
            Image      u  = (Image)gr.Children[5];
            String     x  = u.Source.ToString();
            Label      r  = (Label)gr.Children[1];
            Label      n  = (Label)gr.Children[2];
            Label      y  = (Label)gr.Children[3];
            Label      g  = (Label)gr.Children[4];

            String Nome_Bicho = n.Content.ToString();
            String Idades     = y.Content.ToString();
            String Raca       = r.Content.ToString();
            String genero     = g.Content.ToString();

            foreach (ANIMAL zzs in Container.animais)
            {
                if (zzs.Nome == Nome_Bicho && zzs.Idade == Idades)
                {
                    if (zzs.Favorito == false)
                    {
                        zzs.Favorito = true;
                        Container.favoritos.Add(zzs);

                        b.BeginInit();
                        b.Kind = PackIconKind.Heart;
                        b.EndInit();

                        new Favoritos();
                        break;
                    }
                    else if (zzs.Favorito == true)
                    {
                        Container.favoritos.Remove(zzs);
                        zzs.Favorito = false;

                        b.BeginInit();
                        b.Kind = PackIconKind.HeartOutline;
                        b.EndInit();

                        new Favoritos();
                        break;
                    }
                }
            }
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Button   starbutton = (Button)sender;
            PackIcon icon       = (PackIcon)starbutton.Content;
            Grid     gr         = (Grid)starbutton.Parent;
            Label    name_label = (Label)gr.Children[6];
            Label    age_label  = (Label)gr.Children[8];

            String Name = name_label.Content.ToString();
            String Age  = age_label.Content.ToString();

            foreach (ANIMAL zzs in Container.animais)
            {
                if (zzs.Nome == Name && zzs.Idade == Age)
                {
                    if (zzs.Adotado)
                    {
                        Container.adocoes.Remove(zzs);
                        zzs.Adotado = false;

                        icon.BeginInit();
                        icon.Kind = PackIconKind.StarOutline;
                        icon.EndInit();

                        new ViewPost_Adocoes();
                        new Adocoes();
                        new Inicio();

                        break;
                    }
                    else
                    {
                        zzs.Adotado = true;
                        Container.adocoes.Add(zzs);

                        icon.BeginInit();
                        icon.Kind = PackIconKind.Star;
                        icon.EndInit();

                        new ViewPost_Adocoes();
                        new Adocoes();
                        new Inicio();

                        break;
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Button   heartbutton = (Button)sender;
            PackIcon icon        = (PackIcon)heartbutton.Content;
            Grid     gr          = (Grid)heartbutton.Parent;
            Label    name_label  = (Label)gr.Children[9];
            Label    age_label   = (Label)gr.Children[11];

            String Name = name_label.Content.ToString();
            String Age  = age_label.Content.ToString();

            foreach (ANIMAL zzs in Container.animais)
            {
                if (zzs.Nome == Name && zzs.Idade == Age)
                {
                    if (zzs.Favorito)
                    {
                        Container.favoritos.Remove(zzs);
                        zzs.Favorito = false;

                        icon.BeginInit();
                        icon.Kind = PackIconKind.HeartOutline;
                        icon.EndInit();

                        new Post_MaisInfo();
                        new Favoritos();
                        new Inicio();

                        break;
                    }
                    else
                    {
                        zzs.Favorito = true;
                        Container.favoritos.Add(zzs);

                        icon.BeginInit();
                        icon.Kind = PackIconKind.Heart;
                        icon.EndInit();

                        new Post_MaisInfo();
                        new Favoritos();
                        new Inicio();

                        break;
                    }
                }
            }
        }