static public void DisableAuction(int auctionId) { Auction auction = DB.LoadAuctions().Find(x => x.Id == auctionId); if (Session.contentArea.Content is FullAuctionControl) { FullAuctionControl control = (FullAuctionControl)Session.contentArea.Content; control.dateTimeTb.Text = "AUCTION EXPIRED!"; control.bidItemBtn.Visibility = System.Windows.Visibility.Collapsed; control.bidEndedSp.Visibility = System.Windows.Visibility.Visible; //control.usernameTb.Text = auction.CurrentUser.Username; //control.bidAmountTb.Text = auction.HighestBid.ToString(); //control.endDateTimeTb.Text = auction.End.ToString(); control.endAuctionTb.Inlines.Clear(); control.endAuctionTb.Inlines.Add(new Run("The auction ended at: ")); control.endAuctionTb.Inlines.Add(new Run(auction.End.ToString()) { FontStyle = FontStyles.Italic, FontWeight = FontWeights.SemiBold }); if (auction.CurrentUser != null) { control.endAuctionTb.Inlines.Add(new Run("\nIt was won by the user: "******" with a bid of ")); control.endAuctionTb.Inlines.Add(new Run(auction.HighestBid.ToString()) { FontStyle = FontStyles.Italic, FontWeight = FontWeights.SemiBold }); control.endAuctionTb.Inlines.Add(new Run("€")); BitmapImage auctionImage = new BitmapImage(new Uri(auction.CurrentUser.ProPicPath, UriKind.RelativeOrAbsolute)); control.winnerImg.Source = auctionImage; control.winnerImagePopUp.Source = auction.CurrentUser.ProPicPath; } else { control.endAuctionTb.Inlines.Add(new Run("\nThe auction ended without anyone winning it.")); } } else if (Session.contentArea.Content is AuctionsControl) { AuctionsControl control = (AuctionsControl)Session.contentArea.Content; foreach (var card in control.cardsWp.Children) { AuctionControl cardControl = (AuctionControl)card; if (cardControl.AuctionId == auction.Id) { cardControl.EndDateTime = "AUCTION EXPIRED!"; } } } }
private void RadioButton_Click(object sender, RoutedEventArgs e) { AuctionsControl parent = Helper.GetAncestorOfType <AuctionsControl>(this); if (parent != null) { parent.AuctionControlClicked(this); } }
private void Listener() { IPEndPoint IpRemoto = new IPEndPoint(IPAddress.Any, 0); //accetta datagram da chiunque while (this.listening) { Byte[] receiveBytes; try { receiveBytes = udpClient.Receive(ref IpRemoto); } catch (SocketException socketEx) // if another thread closes udpclient while he's receiving this gets called { break; } //chiamata bloccante. attesa datagram string returnData = Encoding.ASCII.GetString(receiveBytes); if (returnData.Contains("NEW_BID")) { // UPDATE HIGHEST BID List <string> returnDataList = returnData.Split(' ').ToList(); string amount = returnDataList[1]; string itemId = returnDataList[2]; App.Current.Dispatcher.Invoke(() => { if (Session.contentArea.Content is FullAuctionControl) { FullAuctionControl control = (FullAuctionControl)Session.contentArea.Content; control.auction.HighestBid = float.Parse(amount); control.highestBidTb.Text = amount + "€"; } else if (Session.contentArea.Content is AuctionsControl) { AuctionsControl control = (AuctionsControl)Session.contentArea.Content; foreach (var card in control.cardsWp.Children) { AuctionControl cardControl = (AuctionControl)card; if (cardControl.AuctionId.ToString() == itemId) { cardControl.HighestBid = "Highest bid: " + amount + "€"; } } } }); } } }
public MainWindow(double _leftPosition, double _topPosition) { InitializeComponent(); ConnectToServer(); this.Left = _leftPosition; this.Top = _topPosition; usernameBtn.Content = Session.LoggedUser.Username; // start up page UserControl auctionsControl = new AuctionsControl(); ContentArea.Content = auctionsControl; Session.contentArea = ContentArea; }
private void AuctionsBtn_Click(object sender, RoutedEventArgs e) { UserControl auctionsControl = new AuctionsControl(); ContentArea.Content = auctionsControl; }