Exemplo n.º 1
0
 private void PageAdvertisementFileView_Loaded(object sender, RoutedEventArgs e)
 {
     advertisement.MarkAsSaved();
     Console.WriteLine("page advertisement.MarkAsSaved();");
     ButtonDeleteAllAd.IsEnabled = advertisement.AdvertisementItems.Count > 0;
     Loaded -= PageAdvertisementFileView_Loaded;
 }
Exemplo n.º 2
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (SelectedFilial == null)
            {
                return;
            }

            string adFilePath = Path.Combine(SelectedFilial.InfoscreenSettingsFolder, "Advertisement.xml");

            TextBlockTextAdInfoscreen.Text = "Считывание файла с информацией о рекламе: " + adFilePath;

            string fullscreenAdInfoscreenPath =
                Path.Combine(SelectedFilial.InfoscreenSettingsFolder, "FullScreenAdvertisements");

            TextBlockFullscreenAdInfoscreen.Text = "Считывание информации о слайдах Infoscreen " +
                                                   fullscreenAdInfoscreenPath;

            TextBlockTextAdInfoscreen.Visibility = Visibility.Visible;
            FrameTextAdInfoscreen.Visibility     = Visibility.Hidden;

            TextBlockFullscreenAdInfoscreen.Visibility = Visibility.Visible;
            FrameFullscreenAdInfoscreen.Visibility     = Visibility.Hidden;

            await Task.Run(() => {
                Infoscreen.Advertisement.LoadAdvertisement(adFilePath, out advertisement);

                if (Directory.Exists(fullscreenAdInfoscreenPath))
                {
                    fullscreenAdInfoscreen = Infoscreen.FullScreenAd.GetAdItems(fullscreenAdInfoscreenPath, false);
                }

                Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                    if (advertisement.IsReadedSuccessfully)
                    {
                        PageAdvertisementFileView pageAdvertisementFileView =
                            new PageAdvertisementFileView(advertisement);
                        FrameTextAdInfoscreen.Navigate(pageAdvertisementFileView);
                        advertisement.MarkAsSaved();
                    }
                    else
                    {
                        PageAdvertisementFileNotFound pageAdvertisementFileNotFound =
                            new PageAdvertisementFileNotFound();
                        FrameTextAdInfoscreen.Navigate(pageAdvertisementFileNotFound);
                    }

                    if (Directory.Exists(fullscreenAdInfoscreenPath))
                    {
                        PageFullscreenAdInfoscreen pageFullscreenAdInfoscreen = new PageFullscreenAdInfoscreen(fullscreenAdInfoscreen);
                        FrameFullscreenAdInfoscreen.Navigate(pageFullscreenAdInfoscreen);
                    }
                    else
                    {
                        TextBlockFullscreenAdInfoscreen.Text = "Не удается получить доступ (папка не существует): " +
                                                               fullscreenAdInfoscreenPath;
                    }
                }));
            });

            TextBlockTextAdInfoscreen.Visibility = Visibility.Hidden;
            FrameTextAdInfoscreen.Visibility     = Visibility.Visible;

            TextBlockFullscreenAdInfoscreen.Visibility = Visibility.Hidden;
            FrameFullscreenAdInfoscreen.Visibility     = Visibility;
        }