コード例 #1
0
        public Perfil()
        {
            InitializeComponent();

            var mainWindow = (MainWindow)Application.Current.MainWindow;

            ahref = mainWindow.ah;

            img.Source = new BitmapImage(new Uri("images/artur_user.jpg", UriKind.Relative));

            double rating = ahref.getRating(ahref.getUsername());
            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++;
            }
        }
コード例 #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));
            }
        }