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++; } }
private void Licitar_Button_Click(object sender, RoutedEventArgs e) { double value = 0; bool res = double.TryParse(licitar_text.Text, out value); if (!res) { Licitar_error_text.Text = "Insira um valor numérico."; // display error LicitarSuccess.Visibility = Visibility.Collapsed; LicitarError.Visibility = Visibility.Collapsed; LicitarError.Visibility = Visibility.Visible; } else if (value <= current_insp_leilao.getCurrentValue()) { Licitar_error_text.Text = "Insira um valor superior à ultima licitação."; // display error LicitarSuccess.Visibility = Visibility.Collapsed; LicitarError.Visibility = Visibility.Collapsed; LicitarError.Visibility = Visibility.Visible; } else if (value - current_insp_leilao.getCurrentValue() < 1) { Licitar_error_text.Text = "A licitação tem que ser superior por pelo menos 1€"; // display error LicitarSuccess.Visibility = Visibility.Collapsed; LicitarError.Visibility = Visibility.Collapsed; LicitarError.Visibility = Visibility.Visible; } else { MessageBoxResult m_res = MessageBox.Show("Confirmar Licitação de " + value + "€ ?", "Confirmar", MessageBoxButton.YesNo, MessageBoxImage.Question); if (m_res == MessageBoxResult.Yes) { // clean prev error LicitarError.Visibility = Visibility.Collapsed; LicitarSuccess.Visibility = Visibility.Collapsed; // display success LicitarSuccess.Visibility = Visibility.Visible; // clear value licitar_text.Text = ""; Licitacao licit = new Licitacao(ahref.getUsername(), value); current_insp_leilao.addLicitacao(licit); // add to Leilao init_inspect_fields(); } } }
public Leiloes() { InitializeComponent(); var mainWindow = (MainWindow)Application.Current.MainWindow; ahref = mainWindow.ah; username = ahref.getUsername(); Categ.AddHandler(ComboBox.SelectionChangedEvent, new RoutedEventHandler(Search_Options_Changed)); SortPrice.AddHandler(ComboBox.SelectionChangedEvent, new RoutedEventHandler(Search_Options_Changed)); setLeiloes("", "Todos", "Preço menor"); }
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)); } }