Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        private void AddFinallyBtn_Click(object sender, RoutedEventArgs e)
        {
            AddedNews = new News
            {
                Name     = NewsNameTb.Text,
                About    = NewsAboutTb.Text,
                DateNews = DateTime.Now
            };

            if (openFile != null)
            {
                if (!openFile.FileName.Equals(string.Empty))
                {
                    AddedNews.Image = Utillity.GetInstance().ImageToByte(openFile.SafeFileName);
                }
            }
            NewsRepository.GetInstance().Add(AddedNews);
        }
Ejemplo n.º 3
0
        private void SearchTb_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (timer.IsEnabled)
            {
                timer.Stop();
            }

            var         list      = NewsRepository.GetInstance().GetAll();
            List <News> foundNews = new List <News>();

            foreach (var item in list)
            {
                if (item.Name.Contains(SearchTb.Text))
                {
                    foundNews.Add(item);
                }
            }
            if (foundNews.Count != 0)
            {
                NewsPanel.Children.Clear();
            }

            SetNews(foundNews);
        }