Beispiel #1
0
        private void RefreshScrollList(List <Customer> listCustomers)
        {
            //Restart List
            CustomerGrid.Children.Clear();
            CustomerGrid.RowDefinitions.Clear();

            int index = 0;

            //Find each customer in list
            foreach (Customer customer in listCustomers)
            {
                //Add new TrackControl to playlist grid
                CustomerBlock block = new CustomerBlock();
                block.GetCustomerData(customer);
                block.Click += new RoutedEventHandler(Customer_Click);

                //New row to grid per song
                RowDefinition newCustomerRow = new RowDefinition();
                newCustomerRow.Height = new GridLength(50);

                CustomerGrid.RowDefinitions.Add(newCustomerRow);
                Grid.SetRow(block, CustomerGrid.RowDefinitions.Count - 1);


                //White Themes
                if (themeIndex == 1)
                {
                    block.Number.Foreground  = Brushes.Black;
                    block.Name.Foreground    = Brushes.Black;
                    block.Address.Foreground = Brushes.Black;
                    block.Town.Foreground    = Brushes.Black;
                    block.Phone.Foreground   = Brushes.Black;
                    block.Comment.Foreground = Brushes.Black;
                }



                CustomerGrid.Children.Add(block);
                index++;
            }

            index = 0;
        }
Beispiel #2
0
        //Sends current customer data to right panel viewer
        private void Customer_Click(object sender, RoutedEventArgs e)
        {
            CustomerBlock customer = sender as CustomerBlock;

            //To avoid index exceptions
            try
            {
                selected_customer_index = customer.index;

                //If no previous customer has been clicked on, make this one selected
                if (lastCustomer == null)
                {
                    lastCustomer = customer;
                }

                //If different customer is clicked "declick" last customer
                if (customer != lastCustomer)
                {
                    lastCustomer.clicked    = false;
                    lastCustomer.Background = Brushes.Transparent;
                    lastCustomer            = customer;
                }

                DisplayDataPanel(customers[selected_customer_index]);

                //Set selected customer color
                customer.clicked = true;
                BrushConverter bc = new BrushConverter();
                customer.Background = (Brush)bc.ConvertFrom("#4ba7f0");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Index at " + selected_customer_index + " does not exist.", ex.Message, MessageBoxButton.OK, MessageBoxImage.Error);
                selected_customer_index = 0;
            }
        }