private void PrepareListView(ListViewItemCommand listViewItemCommand) { var fileIndex = 0; foreach (var oneFileName in _majorVideoContext.VideoFileNames) { var listViewItem = new ListViewItem { Content = System.IO.Path.GetFileNameWithoutExtension(oneFileName), Tag = fileIndex }; ControlDoubleClick.SetCommand(listViewItem, listViewItemCommand); this.VideoFilesListView.Items.Add(listViewItem); fileIndex++; } if (_majorVideoContext.VideoFileNames.Count > 0) { this.VideoFilesListView.SelectedIndex = 0; ChangeCurrentIndex(0); } var videoFilesListViewBackgroundImagePath = _appConfig.GetVideoFilesListViewBackgroundImagePath(); if (!string.IsNullOrWhiteSpace(videoFilesListViewBackgroundImagePath)) { var image = new Image { Source = new BitmapImage(new Uri(videoFilesListViewBackgroundImagePath)) }; VideoFilesListView.Background = new ImageBrush(image.Source); } }
public VideosPage(MajorVideoContext majorVideoContext, AppConfig appConfig, Window window) { _appConfig = appConfig; _majorVideoContext = majorVideoContext; _window = window; var listViewItemCommand = new ListViewItemCommand(this); InitializeComponent(); VideoPlayer.UnloadedBehavior = MediaState.Close; VideoPlayer.MediaEnded += VideoPlayer_MediaEnded; VideoPlayer.MediaOpened += VideoPlayer_MediaOpened; foreach (var keyValuePair in _majorVideoContext.ResourceInfos) { var viewBox = new Viewbox(); var button = ButtonUtility.CreateButton(keyValuePair.Value.ImagePath, keyValuePair.Key, keyValuePair.Value.MoveEnterImagePath); button.Tag = keyValuePair.Value.Path; button.Click += OpenFolderButton_Click; viewBox.Child = button; this.ToolPanel.Children.Add(viewBox); } var playButton = PreparePlayControlButton(appConfig); PrepareNoneControlVideoButtons(playButton); PrepareListView(listViewItemCommand); if (!string.IsNullOrWhiteSpace(appConfig.VideoPageTitle) && !string.IsNullOrWhiteSpace(majorVideoContext.MajorName)) { var title = $"{majorVideoContext.MajorName}.{appConfig.VideoPageTitle}"; Title = title; } var videoBottomGridBackgroundImagePath = _appConfig.GetVideoBottomGridBackgroundImagePath(); if (!string.IsNullOrWhiteSpace(videoBottomGridBackgroundImagePath)) { var image = new Image { Source = new BitmapImage(new Uri(videoBottomGridBackgroundImagePath)) }; BottomGrid.Background = new ImageBrush(image.Source); } this.Unloaded += VideosPage_Unloaded; BarPageUtility.PrepareBarPage(this, _appConfig); }