private void DoubleAnimation_Completed(object sender, EventArgs e) { // This method after complete animation duration set next publication and check is data in db is changed. ResetCountIndex(); if (publications.Count > 0) { // Check publication expiry date. if (publications[pubIndx].ExpiryDate < DateTime.Now.Date) { publications.RemoveAt(pubIndx); if (!ResetCountIndex()) { pubIndx++; } SlaytShow.Dispatcher.Invoke(() => { SlaytShow.Source = publications[pubIndx].Image; }); InitProgressAnimation(publications[pubIndx].TimeOfView); SlaytShowProgress.Visibility = Visibility.Visible; SlaytShow.Margin = new Thickness(0, 0, 0, 10); pubIndx++; } else { SlaytShow.Dispatcher.Invoke(() => { SlaytShow.Source = publications[pubIndx].Image; }); InitProgressAnimation(publications[pubIndx].TimeOfView); SlaytShowProgress.Visibility = Visibility.Visible; SlaytShow.Margin = new Thickness(0, 0, 0, 10); pubIndx++; } } else { // Set default image when no publications stored in db. SlaytShow.Dispatcher.Invoke(() => { SlaytShow.Source = GetDefaultImage(); }); InitProgressAnimation(DefaultTimeOfView); SlaytShowProgress.Visibility = Visibility.Hidden; SlaytShow.Margin = new Thickness(0, 0, 0, 0); } // Check if have new publications in database inserted to get new publications. string poc = PublicationServices.OnChange(); if (poc != null) { publications = PublicationServices.GetPublications(); PublicationBase.PublicationOnChange = poc; } }
public MainWindow() { InitializeComponent(); // Initialize mysql database connection. Mysqldb.Open(); // Get publications list. publications = PublicationServices.GetPublications(); // Check publications count bigger than 0. if (publications.Count > 0) { //Check first publication expiry date is expired or not. if (publications[0].ExpiryDate < DateTime.Now.Date) { //Remove first publication from list publications.RemoveAt(0); } //Set first index publication to image view. SlaytShow.Dispatcher.Invoke(() => { SlaytShow.Source = publications[0].Image; }); //Set animation slider. InitProgressAnimation(publications[0].TimeOfView); pubIndx++; } else { // Set default image when no publications stored in db. SlaytShow.Source = GetDefaultImage(); InitProgressAnimation(DefaultTimeOfView); SlaytShowProgress.Visibility = Visibility.Hidden; SlaytShow.Margin = new Thickness(0, 0, 0, 0); } }