Exemplo n.º 1
0
        private void initLeilaoCard(Leilao l)
        {
            nome.Text   = l.Nome;
            desc.Text   = l.Descricao;
            estado.Text = l.Estado;

            lei_owner.Text = l.Owner;

            if (l.Estado == "Aberto")
            {
                estado.Foreground = Brushes.Green;
                if (bidstatus == null)
                {
                    status.Visibility = Visibility.Collapsed;
                }
                else
                {
                    if (bidstatus.Equals("leading"))
                    {
                        status.Text       = "À frente";
                        status.Foreground = Brushes.Green;
                        status.Visibility = Visibility.Visible;
                    }
                    else if (bidstatus.Equals("losing"))
                    {
                        status.Text       = "Ultrapassado";
                        status.Foreground = Brushes.Red;
                        status.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        status.Visibility = Visibility.Collapsed;
                    }
                }
            }
            else // Fechado
            {
                estado.Foreground = Brushes.PaleVioletRed;
            }

            if (l.hasLicitacoes())
            {
                licit.Text      = "Ultima licitação:";
                licit_text.Text = " " + l.getCurrentValue() + " €";
            }
            else
            {
                licit.Text      = "Valor inicial:";
                licit_text.Text = " " + l.getCurrentValue() + " €";
            }

            String t = l.timeToEnd();

            if (t == "")
            {
                tempo_text.Text = "0d 00:00:00h " + t;
            }
            else
            {
                tempo_text.Text = " " + t;
            }

            if (l.imgRelative)
            {
                img.Source = new BitmapImage(new Uri(l.imgPath, UriKind.Relative));
            }
            else
            {
                img.Source = new BitmapImage(new Uri(l.imgPath, UriKind.Absolute));
            }
        }
Exemplo n.º 2
0
        public void init_inspect_fields()
        {
            // init fields
            Inspect_lei_nome.Text   = current_insp_leilao.Nome;
            Inspect_lei_desc.Text   = current_insp_leilao.Descricao;
            Inspect_lei_estado.Text = current_insp_leilao.Estado;

            String is_owner = "";

            if (current_insp_leilao.Owner == ahref.getUsername())
            {
                is_owner = " (Tu)";
            }

            Inspect_lei_owner.Text   = current_insp_leilao.Owner + is_owner;
            LicitarOption.Visibility = Visibility.Visible;


            double rating = ahref.getRating(current_insp_leilao.Owner);
            int    i      = 0;

            foreach (UIElement elem in Inspect_lei_rating.Children)
            {
                if (i < rating)
                {
                    ((MaterialDesignThemes.Wpf.PackIcon)elem).Foreground = Brushes.Gold;
                }
                else
                {
                    ((MaterialDesignThemes.Wpf.PackIcon)elem).Foreground = Brushes.LightGray;
                }
                i++;
            }

            if (current_insp_leilao.Estado == "Aberto")
            {
                Inspect_lei_estado.Foreground = Brushes.Green;
                Inspect_lei_tempo.Text        = "Tempo restante: " + current_insp_leilao.timeToEnd();

                if (current_insp_leilao.isBidding(username))
                {
                    if (current_insp_leilao.Owner != username && current_insp_leilao.isBidding(username) && ahref.getLastLicitacaoUser(current_insp_leilao) == username)
                    {
                        Inspect_status.Text       = "À frente";
                        Inspect_status.Foreground = Brushes.Green;
                        Inspect_status.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        Inspect_status.Text       = "Ultrapassado";
                        Inspect_status.Foreground = Brushes.Red;
                        Inspect_status.Visibility = Visibility.Visible;
                    }
                }
            }
            else // Fechado
            {
                Inspect_lei_estado.Foreground = Brushes.PaleVioletRed;
                Inspect_lei_tempo.Text        = "Tempo restante: " + "0d 00:00:00h";

                // hide
                LicitarOption.Visibility = Visibility.Collapsed;
            }

            if (current_insp_leilao.hasLicitacoes())
            {
                String users_licit = "";
                if (current_insp_leilao.getCurrentValueUser() == ahref.getUsername())
                {
                    users_licit = "(Teu)";
                }
                Inspect_lei_ult_licit.Text = "Última licitação: " + current_insp_leilao.getCurrentValue().ToString() + " € " + users_licit;
            }
            else
            {
                Inspect_lei_ult_licit.Text = "Valor inicial: " + current_insp_leilao.getCurrentValue().ToString() + " €";
            }

            if (current_insp_leilao.imgRelative)
            {
                Inspect_lei_img.Source = new BitmapImage(new Uri(current_insp_leilao.imgPath, UriKind.Relative));
            }
            else
            {
                Inspect_lei_img.Source = new BitmapImage(new Uri(current_insp_leilao.imgPath, UriKind.Absolute));
            }
        }