private void ClientInfoContainer_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { this.ShowClientDescriptionImages(); Client selectedClient = this.InfoAboutClientGrid.DataContext as Client; if (Basket.PurchasedItems.Count > 0 || Basket.RentedItems.Count > 0) { this.MakeOrderButton.Visibility = System.Windows.Visibility.Visible; this.MakeOrderButton.Click += (sdr, args) => { this.OnMakeOrderButtonClick((this.InfoAboutClientGrid.DataContext as Client).Name, new RoutedEventArgs()); }; } var baseDirectory = App.FileManager.GetBaseDirectory("Client"); ElementRenderer.VisualizeImageInPanel(this.PictureBoxContainer, selectedClient.Name, baseDirectory); this.NameText.Text = selectedClient.Name; this.AgeText.Text = selectedClient.Age.ToString(); this.AddressText.Text = selectedClient.Address; this.PhoneText.Text = selectedClient.MobileNumber; this.VizualizeClientOrders(selectedClient.Name); }
private void AddItemToBasketGrid(IDescription itemDescription) { Grid newItemGrid = new Grid(); newItemGrid.Margin = new Thickness(5, 0, 0, 10); newItemGrid.Height = 50; var imageColumn = new ColumnDefinition(); imageColumn.Width = new GridLength(50); newItemGrid.ColumnDefinitions.Add(imageColumn); newItemGrid.ColumnDefinitions.Add(new ColumnDefinition()); ElementRenderer.VisualizeImageInPanel( newItemGrid, itemDescription.Name, App.FileManager.GetBaseDirectory(itemDescription.GetType().Name)); var textBlock = new TextBlock(); textBlock.Text = itemDescription.Name; textBlock.VerticalAlignment = System.Windows.VerticalAlignment.Center; textBlock.Margin = new Thickness(5, 0, 0, 0); textBlock.FontSize = 15; Grid.SetColumn(textBlock, 1); newItemGrid.Children.Add(textBlock); this.BasketElementsStackPanel.Children.Add(newItemGrid); }
public InformationAboutCatalogItem(IDescription catalogItem, Uri path) : this() { ElementRenderer.VisualizeImageInPanel(this.PictureBoxContainer, catalogItem.Name, path); this.NameText.Text = catalogItem.Name; this.GenreText.Text = string.Join(", ", catalogItem.Genres); this.YearText.Text = catalogItem.ReleaseYear; bool isInStock = (catalogItem as IStockable).IsInStock; this.IsInStockText.Text = isInStock ? "Available" : "Not Available"; this.IsInStockText.Foreground = isInStock ? Brushes.Green : Brushes.Red; Button stockButton = null; if (catalogItem is ISaleable) { this.PriceImage.Visibility = Visibility.Visible; this.SellPriceTextBlock.Text = string.Format("{0:C}", (catalogItem as ISaleable).Price); this.SellButton.Visibility = Visibility.Visible; stockButton = this.SellButton; // Set Click event to Sell Button this.SellButton.Click += (sender, args) => { Basket.PurchasedItems.Add(catalogItem as ISaleable); }; } else if (catalogItem is IRentable) { this.PricePerDayImage.Visibility = Visibility.Visible; this.RentalPricePerDayTextBlock.Text = string.Format("{0:C}", (catalogItem as IRentable).PricePerDay); this.RentButton.Visibility = Visibility.Visible; stockButton = this.RentButton; // Set Click event to Rent Button this.RentButton.Click += (sender, args) => { RentOptionScreen rentScreen = new RentOptionScreen(catalogItem as IRentable); rentScreen.OldContent = this.Content; this.Content = rentScreen.Content; this.DataContext = rentScreen.DataContext; }; } if (stockButton != null && !isInStock) { stockButton.IsEnabled = false; } this.CloseButton.Focus(); }
void VizualizeClientOrders(string clientName) { IList <string> userOrders = App.FileManager.GetUserOrdersInfo(clientName); this.ClientStockItems.Children.Clear(); if (userOrders.Count > 0) { this.ClientStockItems.Background = Brushes.White; } else { this.ClientStockItems.Background = Brushes.Gray; } foreach (var orderInfo in userOrders) { var components = orderInfo.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); Grid newItemGrid = new Grid(); newItemGrid.Margin = new Thickness(5, 5, 0, 10); newItemGrid.Height = 50; var imageColumn = new ColumnDefinition(); imageColumn.Width = new GridLength(50); newItemGrid.ColumnDefinitions.Add(imageColumn); newItemGrid.ColumnDefinitions.Add(new ColumnDefinition()); ElementRenderer.VisualizeImageInPanel( newItemGrid, components[1], App.FileManager.GetBaseDirectory(components[0])); var textBlock = new TextBlock(); textBlock.VerticalAlignment = System.Windows.VerticalAlignment.Center; textBlock.Margin = new Thickness(5, 0, 0, 0); textBlock.FontSize = 15; textBlock.Text = string.Format("{0} [{1}] ", components[1], components[2]); if (components[0] == "Game" || components[0] == "Music") { textBlock.Text += string.Format("| Price: {0:C}", decimal.Parse(components[3])); } else if (components[0] == "Movie") { textBlock.Text += string.Format("| Rented: {0} - {1} | Price: {2:C}", components[3], components[4], decimal.Parse(components[5])); } Grid.SetColumn(textBlock, 1); newItemGrid.Children.Add(textBlock); this.ClientStockItems.Children.Add(newItemGrid); } }