/// <summary> /// 游戏库瀑布流初始化 /// </summary> private void GameLibraryPanel_Init() { List <System.Windows.Media.SolidColorBrush> bushLst = new List <System.Windows.Media.SolidColorBrush> { System.Windows.Media.Brushes.CornflowerBlue, System.Windows.Media.Brushes.IndianRed, System.Windows.Media.Brushes.Orange, System.Windows.Media.Brushes.ForestGreen }; if (gameInfolst != null) { for (int i = 0; i < gameInfolst.Count; i++) { Border back = new Border(); GameLibraryPanel.RegisterName("game" + i, back); back.Name = "game" + i; Grid gd = new Grid(); back.Width = 150; back.Margin = new Thickness(5); back.Child = gd; back.Background = bushLst[i % 4]; TextBlock tb = new TextBlock(); tb.Text = gameInfolst[i].GameName; tb.Foreground = System.Windows.Media.Brushes.White; tb.HorizontalAlignment = HorizontalAlignment.Left; tb.VerticalAlignment = VerticalAlignment.Bottom; tb.Margin = new Thickness(3); gd.Children.Add(tb); System.Windows.Controls.Image ico = new System.Windows.Controls.Image(); ico.Source = ImageProcFunc.ImageToBitmapImage(ImageProcFunc.GetAppIcon(gameInfolst[i].FilePath)); ico.HorizontalAlignment = HorizontalAlignment.Center; ico.VerticalAlignment = VerticalAlignment.Center; ico.Height = 50; ico.Width = 50; gd.Children.Add(ico); back.MouseEnter += Border_MouseEnter; back.MouseLeave += Border_MouseLeave; back.MouseLeftButtonDown += Border_MouseLeftButtonDown; GameLibraryPanel.Children.Add(back); } } }
/// <summary> /// 游戏库瀑布流初始化 /// </summary> private void GameLibraryPanel_Init() { Random random = new Random(); var bushLst = new List <SolidColorBrush> { System.Windows.Media.Brushes.CornflowerBlue, System.Windows.Media.Brushes.IndianRed, System.Windows.Media.Brushes.Orange, System.Windows.Media.Brushes.ForestGreen }; if (gameInfoList != null) { for (var i = 0; i < gameInfoList.Count; i++) { var tb = new TextBlock() { Text = gameInfoList[i].GameName, Foreground = System.Windows.Media.Brushes.White, VerticalAlignment = VerticalAlignment.Bottom, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(3) }; var ico = new System.Windows.Controls.Image() { Source = ImageProcFunc.ImageToBitmapImage(ImageProcFunc.GetAppIcon(gameInfoList[i].FilePath)), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Height = 64, Width = 64 }; var gd = new Grid(); gd.Children.Add(ico); gd.Children.Add(tb); var back = new Border() { Name = "game" + i, Width = 150, Child = gd, Margin = new Thickness(5), Background = bushLst[i % 4], }; back.MouseEnter += Border_MouseEnter; back.MouseLeave += Border_MouseLeave; back.MouseLeftButtonDown += Back_MouseLeftButtonDown; GameLibraryPanel.RegisterName("game" + i, back); GameLibraryPanel.Children.Add(back); } } var textBlock = new TextBlock() { Text = Application.Current.Resources["MainWindow_ScrollViewer_AddNewGame"].ToString(), Foreground = System.Windows.Media.Brushes.White, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(3) }; var grid = new Grid(); grid.Children.Add(textBlock); var border = new Border() { Name = "AddNewName", Width = 150, Child = grid, Margin = new Thickness(5), Background = (SolidColorBrush)this.Resources["Foreground"] }; border.MouseEnter += Border_MouseEnter; border.MouseLeave += Border_MouseLeave; border.MouseLeftButtonDown += Border_MouseLeftButtonDown; GameLibraryPanel.RegisterName("AddNewGame", border); GameLibraryPanel.Children.Add(border); }