public MainWindow() { DataContext = this; timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; timer.Tick += (s, r) => { var news = NewsRepository.GetInstance().GetAll(); if (NewsCount < news.Count()) { NewsPanel.Children.Clear(); SetNews(news.ToList()); NewsCount = news.Count(); } }; timer.Start(); InitializeComponent(); var schedule = SchedulesRepository.GetInstance().GetAll(); foreach (var item in schedule) { if (item.Date.Date.Equals(DateTime.Today)) { ScheduleOfOneUc scheduleOfOne = new ScheduleOfOneUc(item); WorksPanel.Children.Add(scheduleOfOne); } } SetTasks(); }
private void ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var listView = (sender as ListView); var exp = (listView.Parent as Expander); var h = int.Parse((listView.SelectedItem as TextBlock).Text.Substring(0, (listView.SelectedItem as TextBlock).Text.IndexOf(':'))); Schedules scheduleNew = new Schedules { TimeStart = new DateTime(CalendarSmall.SelectedDate.Value.Year, CalendarSmall.SelectedDate.Value.Month, CalendarSmall.SelectedDate.Value.Day, h, 0, 0), Date = CalendarSmall.SelectedDate.Value, Duration = 1, Coach = StaffRepository.GetInstance().Get(int.Parse(exp.DataContext.ToString())), Services = new AdditionalServices() }; SchedulesRepository.GetInstance().Add(scheduleNew); var schedule = SchedulesRepository.GetInstance().GetAll(); list = new List <Schedules>(); coachList = new List <Staff>(); foreach (var item in schedule) { if (item.Date == CalendarSmall.SelectedDate) { coachList.Add(item.Coach); list.Add(item); } } var listSchedule = list.Where(item => item.Coach.Id == int.Parse(exp.DataContext.ToString())).ToList(); exp.Content = null; exp.Content = SetGraficOfOne(listSchedule); }
private void NewsNameCmb_SelectionChanged(object sender, SelectionChangedEventArgs e) { foreach (var item in SchedulesRepository.GetInstance().GetAll()) { if (item.Coach.Id == ((sender as ComboBox).SelectedItem as Staff).Id) { Schedules.Add(item); } } }
private void SetCoach() { CoachesPanel.Children.Clear(); var schedule = SchedulesRepository.GetInstance().GetAll(); list = new List <Schedules>(); coachList = new List <Staff>(); foreach (var item in schedule) { if (item.Date == CalendarSmall.SelectedDate) { coachList.Add(item.Coach); list.Add(item); } } foreach (var l in list) { Expander exp; StackPanel spCoach = null; List <Schedules> listOne; foreach (var c in coachList) { listOne = list.Where(item => item.Coach.Id == c.Id).ToList(); if (l.Coach.Id == c.Id) { if (spCoach is null) { spCoach = new StackPanel { Orientation = Orientation.Horizontal }; BitmapImage bitmap; if (File.Exists(c.ProfileImg.Name + c.ProfileImg.Extension)) { bitmap = new BitmapImage(new Uri(System.IO.Path.GetFullPath(c.ProfileImg.Name + c.ProfileImg.Extension))); } else { bitmap = new BitmapImage(new Uri(System.IO.Path.GetFullPath(Utillity.GetInstance().ByteToImage(c.ProfileImg)))); } spCoach.Children.Add(new Ellipse { Width = 60, Height = 60, Fill = new ImageBrush(bitmap) }); spCoach.Children.Add(new TextBlock { Text = c.Name + " " + c.SurName, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(15, 0, 0, 0), FontSize = 18, }); } exp = new Expander { Header = spCoach, Content = SetGraficOfOne(listOne), DataContext = c.Id }; CoachesPanel.Children.Add(exp); } } } }