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);
        }
        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);
            }
        }
Пример #4
0
        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();
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            this.Closing -= this.Window_Closing;
            e.Cancel      = true;

            DoubleAnimation animation = ElementRenderer.WindowAnimation(this);

            this.BeginAnimation(Window.OpacityProperty, animation);

            animation.Completed += (s, _) => this.Close();
            this.BeginAnimation(UIElement.OpacityProperty, animation);
        }
 private void OnCheckBoxSelection(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(this.SearchBox.Text) && this.SearchBox.Text != "Search by name")
     {
         ElementRenderer.VizualizeItemsBySelectedGenres(
             this.AllMusicPanel, this.GenrePanel, App.Resources.Music, this.SearchBox.Text);
     }
     else
     {
         ElementRenderer.VizualizeItemsBySelectedGenres(
             this.AllMusicPanel, this.GenrePanel, App.Resources.Music);
     }
 }
Пример #7
0
        public static void VizualizeNewClientsSearchResult(ListBox listBox, Grid grid, TextBox textBox, IList <Client> list)
        {
            string        searchedText = textBox.Text.ToLower();
            List <Client> result       = new List <Client>();

            if (!string.IsNullOrEmpty(searchedText) && !searchedText.Equals("search by name"))
            {
                result = list.ToList().FindAll(item => item.Name.ToLower().Contains(searchedText));
            }
            else
            {
                result = new List <Client>(list);
            }

            ElementRenderer.VizualizeClientNamesToPanel(listBox, result);
        }
        public ClientsLibrary()
        {
            this.InitializeComponent();

            try
            {
                ElementRenderer.VizualizeClientNamesToPanel(this.ClientsListBox, App.Resources.Clients);
                clientInfoContainer = this.InfoAboutClientGrid;

                this.HideClientDescriptionImages();
                this.ShowBasketItemsToGrid();
            }
            catch (Exception)
            {
                new ApplicationProccessException();
            }
        }
Пример #9
0
        public static void VizualizeNewSearchResultByName <T>(Panel allItemsPanel, TextBox searchBox, IList <T> items)
            where T : IDescription
        {
            string   searchedText = searchBox.Text.ToLower();
            List <T> result       = new List <T>();

            if (!string.IsNullOrEmpty(searchedText) && !searchedText.Equals("search by name"))
            {
                result = items.ToList().FindAll(item => item.Name.ToLower().Contains(searchedText));
            }
            else
            {
                result = new List <T>(items);
            }

            ElementRenderer.VisualizeAllElementsToPanel(allItemsPanel, result);
        }
Пример #10
0
        public static void VizualizeItemsBySelectedGenres <T>(
            Panel panelToVisualize, Panel selectedGenresPanel, IList <T> items, string search)
            where T : IDescription
        {
            IList <string> selectedGenres = ElementRenderer.GetSelectedGenres(selectedGenresPanel);

            if (selectedGenres.Count > 0)
            {
                IList <T> result = new List <T>();

                foreach (var item in items)
                {
                    if (item.Genres.Count >= selectedGenres.Count)
                    {
                        bool valid = true;

                        foreach (var genre in selectedGenres)
                        {
                            if (!item.Genres.Contains(genre))
                            {
                                valid = false;
                                break;
                            }
                        }

                        if (valid && item.Name.ToLower().Contains(search.ToLower()))
                        {
                            result.Add(item);
                        }
                    }
                }

                ElementRenderer.VisualizeAllElementsToPanel(panelToVisualize, result);
            }
            else
            {
                ElementRenderer.VisualizeAllElementsToPanel(panelToVisualize, items);
            }
        }
 private void OnSearchBoxLostFocus(object sender, RoutedEventArgs e)
 {
     ElementRenderer.SearchBoxPutContent(this.SearchBox);
 }
 private void OnSearchBoxGotFocus(object sender, RoutedEventArgs e)
 {
     ElementRenderer.SearchBoxRemoveContent(this.SearchBox);
 }
 private void OnSearchButtonClick(object sender, RoutedEventArgs e)
 {
     ElementRenderer.VizualizeNewSearchResultByName <Music>(this.AllMusicPanel, this.SearchBox, App.Resources.Music);
     ElementRenderer.ResetCheckBoxedGenredInExpander(this.GenrePanel);
 }
        private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            DoubleAnimation animation = ElementRenderer.WindowAnimation(this, 0, 1);

            this.BeginAnimation(Window.OpacityProperty, animation);
        }
 private void OnResetCheckBoxedGenresButtonClick(object sender, RoutedEventArgs e)
 {
     ElementRenderer.ResetCheckBoxedGenredInExpander(this.GenrePanel);
 }
 public MusicLibrary()
 {
     this.InitializeComponent();
     ElementRenderer.VisualizeAllElementsToPanel <Music>(this.AllMusicPanel, App.Resources.Music);
 }
 public MoviesLibrary()
 {
     this.InitializeComponent();
     ElementRenderer.VisualizeAllElementsToPanel <Movie>(this.AllMoviesPanel, App.Resources.Movies);
 }
 private void OnSearchButtonClick(object sender, RoutedEventArgs e)
 {
     ElementRenderer.VizualizeNewClientsSearchResult(
         this.ClientsListBox, this.InfoAboutClientGrid, this.SearchByNameBox, App.Resources.Clients);
 }