Advertisement
jovanovski

КИ Лаб4 C#

Mar 18th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15.  
  16. namespace lab4
  17. {
  18.     /// <summary>
  19.     /// Interaction logic for MainWindow.xaml
  20.     /// </summary>
  21.     public partial class MainWindow : Window
  22.     {
  23.         public MainWindow()
  24.         {
  25.             InitializeComponent();
  26.             List<NBATeam> timovi = Data.GetTeams();
  27.             lstTeams.ItemsSource = timovi;
  28.             lstTeams.SelectedIndex = 0;
  29.         }
  30.  
  31.         private void lstTeams_SelectionChanged(object sender, SelectionChangedEventArgs e)
  32.         {
  33.             filterPlayers();    
  34.         }
  35.  
  36.         private void filterPlayers() {
  37.             NBATeam tim = (NBATeam) lstTeams.SelectedItem;
  38.             List<String> igraci = new List<string>();
  39.             if (tim != null)
  40.             {
  41.                 foreach (NBAPlayer igrac in tim.Players)
  42.                 {
  43.                     if (Rd1.IsChecked == true)
  44.                     {
  45.                         igraci.Add(igrac.Name + " - " + igrac.PointsPerGame);
  46.                     }
  47.                     else
  48.                     {
  49.                         igraci.Add(igrac.Name + " - " + igrac.MinutesPlayed);
  50.                     }
  51.                 }
  52.                 lstPlayers.ItemsSource = igraci;
  53.                 lstPlayers.Background = tim.TeamColor;
  54.  
  55.             }
  56.         }
  57.  
  58.         private void Rd2_Checked(object sender, RoutedEventArgs e)
  59.         {
  60.             filterPlayers();
  61.         }
  62.  
  63.         private void Rd1_Checked(object sender, RoutedEventArgs e)
  64.         {
  65.             filterPlayers();
  66.         }
  67.     }
  68.  
  69.     public class ImageConverter : IValueConverter {
  70.        
  71.         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  72.         {
  73.             string imgPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), (String)value);
  74.             return new BitmapImage(new Uri(imgPath));
  75.         }
  76.  
  77.         public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  78.         {
  79.             throw new NotImplementedException();
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement