public VZ_PagePoint() { InitializeComponent(); imgList = new List <Image>(); bmWhite = VZMethods.getBitmap(@"pack://*****:*****@"pack://application:,,,/Res/point_gray.png"); VerticalAlignment = VerticalAlignment.Bottom; HorizontalAlignment = HorizontalAlignment.Center; }
public MainWindow() { InitializeComponent(); VZ_AppHelper.GetInstance(); pageTotal = VZ_AppHelper.GetInstance().appList.Count / 3; if (VZ_AppHelper.GetInstance().appList.Count % 3 > 0) { pageTotal++; } /*主界面4个行 * 第一行,控制栏 * 第二行,用户信息 * 第三行,应用选择菜单 * 第四行,留空 */ RowDefinition row1 = new RowDefinition(); row1.Height = new GridLength(126); RowDefinition row2 = new RowDefinition(); row2.Height = new GridLength(100); RowDefinition row3 = new RowDefinition(); row3.Height = new GridLength(1, GridUnitType.Star); RowDefinition row4 = new RowDefinition(); row4.Height = new GridLength(80); RowDefinition row5 = new RowDefinition(); row5.Height = new GridLength(80); mainGrid.RowDefinitions.Add(row1); mainGrid.RowDefinitions.Add(row2); mainGrid.RowDefinitions.Add(row3); mainGrid.RowDefinitions.Add(row4); mainGrid.RowDefinitions.Add(row5); //第一行Grid //图标、游戏名字、退出游戏、音量组件 Grid grid1 = new Grid(); Grid.SetRow(grid1, 0); //grid1.Background = new SolidColorBrush(Color.FromArgb(128,93, 195,255)); Grid grid10 = new Grid(); Grid.SetRow(grid10, 0); grid10.Margin = new Thickness(0, 0, 166, 0); mainGrid.Children.Add(grid10); gameTopImg = new Image(); grid10.Children.Add(gameTopImg); gameTopImg.Stretch = Stretch.UniformToFill; Image topImage = VZMethods.getImageContent(@"Res\top_bar.png"); topImage.Stretch = Stretch.Fill; grid10.Children.Add(topImage); mainGrid.Children.Add(grid1); ColumnDefinition col11 = new ColumnDefinition(); ColumnDefinition col12 = new ColumnDefinition(); ColumnDefinition col13 = new ColumnDefinition(); ColumnDefinition col14 = new ColumnDefinition(); ColumnDefinition col15 = new ColumnDefinition(); col11.Width = new GridLength(155, GridUnitType.Pixel); col12.Width = new GridLength(526, GridUnitType.Pixel); col13.Width = new GridLength(1, GridUnitType.Star); col14.Width = new GridLength(410, GridUnitType.Pixel); col15.Width = new GridLength(166, GridUnitType.Pixel); grid1.ColumnDefinitions.Add(col11); grid1.ColumnDefinitions.Add(col12); grid1.ColumnDefinitions.Add(col13); grid1.ColumnDefinitions.Add(col14); grid1.ColumnDefinitions.Add(col15); //gameTopImg = new Image(); //grid1.Children.Add(gameTopImg); //Grid.SetColumnSpan(gameTopImg, 4); //gameTopImg.Stretch = Stretch.UniformToFill; //Image topImage = VZMethods.getImageContent(@"Res\top_bar.png"); //topImage.Stretch = Stretch.Fill; //Grid.SetColumnSpan(topImage, 4); //grid1.Children.Add(topImage); Grid grid11 = new Grid(); Grid.SetColumn(grid11, 0); grid11.Width = 144; grid11.Height = 114; grid11.VerticalAlignment = VerticalAlignment.Center; grid11.HorizontalAlignment = HorizontalAlignment.Center; grid1.Children.Add(grid11); playGameImg = new Image(); playGameImg.Stretch = Stretch.UniformToFill; grid11.Children.Add(playGameImg); playGameImg.Width = 144; playGameImg.Height = 114; playGameImg.Stretch = Stretch.UniformToFill; playGameImg.Margin = new Thickness(7.5); playGameImg.HorizontalAlignment = HorizontalAlignment.Center; playGameImg.VerticalAlignment = VerticalAlignment.Center; Image img = VZMethods.getImageContent(@"Res\game_border.png"); grid11.Children.Add(img); img.HorizontalAlignment = HorizontalAlignment.Center; img.VerticalAlignment = VerticalAlignment.Center; tbState = new TextBlock(); tbState.Text = "准备就绪"; tbState.Foreground = new SolidColorBrush(Colors.White); tbState.FontSize = 20; tbState.TextAlignment = TextAlignment.Center; tbState.HorizontalAlignment = HorizontalAlignment.Center; tbState.VerticalAlignment = VerticalAlignment.Center; grid11.Children.Add(tbState); tbGame = new TextBlock(); tbGame.TextAlignment = TextAlignment.Left; tbGame.HorizontalAlignment = HorizontalAlignment.Left; tbGame.VerticalAlignment = VerticalAlignment.Center; tbGame.FontSize = 40; tbGame.Foreground = new SolidColorBrush(Colors.White); tbGame.Margin = new Thickness(20, 0, 0, 0); Grid.SetColumn(tbGame, 1); grid1.Children.Add(tbGame); VZ_VolumeController volumeCtr = new VZ_VolumeController(); Grid.SetColumn(volumeCtr, 3); grid1.Children.Add(volumeCtr); quitBt = VZMethods.getNoBgImageButton(VZMethods.getImageContent(@"Res\quit_game.png")); Grid.SetColumn(quitBt, 1); quitBt.Height = 50; quitBt.Visibility = Visibility.Hidden; quitBt.VerticalAlignment = VerticalAlignment.Center; quitBt.HorizontalAlignment = HorizontalAlignment.Right; quitBt.Click += QuitBt_Click; grid1.Children.Add(quitBt); quitBt.Margin = new Thickness(0, 0, 50, 0); Image tmpImg = VZMethods.getImageContent(@"Res\bt_help3.png"); tmpImg.Stretch = Stretch.Fill; tmpImg.Width = 166; tmpImg.Height = 126; Tile tile = VZMethods.getNoBgImageButton(tmpImg); tile.Click += Tile_Click; tile.VerticalAlignment = VerticalAlignment.Center; tile.HorizontalAlignment = HorizontalAlignment.Center; tile.Width = 166; tile.Height = 126; tile.Margin = new Thickness(-10); Grid.SetColumn(tile, 4); grid1.Children.Add(tile); Grid grid12 = new Grid(); grid12.Margin = new Thickness(0, 20, 50, 20); grid12.Background = new ImageBrush(VZMethods.getBitmap("pack://*****:*****@"/Res/time_bg.png")); Grid.SetColumn(grid12, 2); grid12.HorizontalAlignment = HorizontalAlignment.Center; grid1.Children.Add(grid12); StackPanel sp = new StackPanel(); sp.Margin = new Thickness(20, 10, 40, 10); grid12.Children.Add(sp); sp.HorizontalAlignment = HorizontalAlignment.Center; sp.Orientation = Orientation.Horizontal; TextBlock tb = new TextBlock(); tb.Text = "倒计时"; tb.Margin = new Thickness(0, 0, 30, 0); tb.FontSize = 20; tb.HorizontalAlignment = HorizontalAlignment.Right; tb.Foreground = new SolidColorBrush(Colors.White); tb.VerticalAlignment = VerticalAlignment.Center; sp.Children.Add(tb); tbGameTime = new TextBlock(); tbGameTime.Text = "00 : 00 : 00"; tbGameTime.FontSize = 50; tbGameTime.HorizontalAlignment = HorizontalAlignment.Left; tbGameTime.Foreground = new SolidColorBrush(Colors.White); tbGameTime.VerticalAlignment = VerticalAlignment.Center; sp.Children.Add(tbGameTime); Button payBt = VZMethods.getNoBgImageButton(VZMethods.getImageContent(@"Res\bt_payagain.png")); payBt.Height = 60; payBt.Margin = new Thickness(30, 0, 0, 0); sp.Children.Add(payBt); payBt.Click += PayBt_Click; //第二行Grid //用户头像、用户名、剩余时间、时间 Grid grid2 = new Grid(); grid2.Margin = new Thickness(160, 0, 160, 0); Grid.SetRow(grid2, 1); mainGrid.Children.Add(grid2); ColumnDefinition col21 = new ColumnDefinition(); ColumnDefinition col22 = new ColumnDefinition(); ColumnDefinition col23 = new ColumnDefinition(); ColumnDefinition col24 = new ColumnDefinition(); col21.Width = new GridLength(100, GridUnitType.Pixel); col22.Width = new GridLength(300, GridUnitType.Pixel); col23.Width = new GridLength(1, GridUnitType.Star); col24.Width = new GridLength(400, GridUnitType.Pixel); grid2.ColumnDefinitions.Add(col21); grid2.ColumnDefinitions.Add(col22); grid2.ColumnDefinitions.Add(col23); grid2.ColumnDefinitions.Add(col24); //headerImg = new Image(); //headerImg.Margin = new Thickness(10); //Grid.SetColumn(headerImg, 0); //VZMethods.getNetImage(headerImg, VZ_AppHelper.getSingleton().payInfo.headimgurl); //grid2.Children.Add(headerImg); //tbName = new TextBlock(); //tbName.Text = VZ_AppHelper.getSingleton().payInfo.nickname; //tbName.FontSize = 25; //tbName.Margin = new Thickness(0, 0, 0, 30); //tbName.Foreground = new SolidColorBrush(Colors.LightBlue); //tbName.VerticalAlignment = VerticalAlignment.Center; //Grid.SetColumn(tbName, 1); //grid2.Children.Add(tbName); //if(VZ_AppHelper.getSingleton().systemInfo.isDebug) //{ // tbName.Text = VZ_AppHelper.getSingleton().payInfo.nickname + " **调试模式**"; //} //TextBlock tb = new TextBlock(); //tb.Text = "微信已登录"; //tb.FontSize = 12.5; //tb.Margin = new Thickness(0, 30, 0, 0); //tb.Foreground = new SolidColorBrush(Colors.LightBlue); //tb.VerticalAlignment = VerticalAlignment.Center; //Grid.SetColumn(tb, 1); //grid2.Children.Add(tb); tbTime = new TextBlock(); tbTime.Text = "00:00"; tbTime.HorizontalAlignment = HorizontalAlignment.Right; tbTime.FontSize = 20; tbTime.Foreground = new SolidColorBrush(Colors.LightBlue); tbTime.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(tbTime, 3); grid2.Children.Add(tbTime); //第三行Grid //←、游戏1、游戏2、游戏3、→ gridReady = new Grid(); Grid.SetRow(gridReady, 2); Image readyImg = VZMethods.getImageContent(@"Res\main_ready.png"); gridReady.Children.Add(readyImg); Button readyBt = VZMethods.getNoBgImageButton(VZMethods.getImageContent(@"Res\bt_ok3.png")); readyBt.Width = 405; readyBt.Height = 90; readyBt.HorizontalAlignment = HorizontalAlignment.Center; readyBt.HorizontalContentAlignment = HorizontalAlignment.Center; readyBt.VerticalContentAlignment = VerticalAlignment.Center; readyBt.VerticalAlignment = VerticalAlignment.Bottom; readyBt.Margin = new Thickness(0, 0, 0, -45); readyBt.Click += ReadyBt_Click; gridReady.Children.Add(readyBt); mainGrid.Children.Add(gridReady); grid3 = new Grid(); grid3.Visibility = Visibility.Hidden; Grid.SetRow(grid3, 2); mainGrid.Children.Add(grid3); ColumnDefinition col31 = new ColumnDefinition(); ColumnDefinition col32 = new ColumnDefinition(); ColumnDefinition col33 = new ColumnDefinition(); ColumnDefinition col34 = new ColumnDefinition(); ColumnDefinition col35 = new ColumnDefinition(); col31.Width = new GridLength(160); col32.Width = new GridLength(1, GridUnitType.Star); col33.Width = new GridLength(1, GridUnitType.Star); col34.Width = new GridLength(1, GridUnitType.Star); col35.Width = new GridLength(160); grid3.ColumnDefinitions.Add(col31); grid3.ColumnDefinitions.Add(col32); grid3.ColumnDefinitions.Add(col33); grid3.ColumnDefinitions.Add(col34); grid3.ColumnDefinitions.Add(col35); btLeft = VZMethods.getNoBgImageButton(VZMethods.getImageContent(@"Res\left_disable.png")); btLeft.Height = 100; Grid.SetColumn(btLeft, 0); grid3.Children.Add(btLeft); btLeft.VerticalAlignment = VerticalAlignment.Center; btLeft.HorizontalAlignment = HorizontalAlignment.Center; btLeft.Click += BtLeft_Click; btRight = VZMethods.getNoBgImageButton(VZMethods.getImageContent(@"Res\right_disable.png")); btRight.Height = 100; Grid.SetColumn(btRight, 4); grid3.Children.Add(btRight); btRight.VerticalAlignment = VerticalAlignment.Center; btRight.HorizontalAlignment = HorizontalAlignment.Center; btRight.Click += BtRight_Click; //增加app娱乐项目 int counter = 0; foreach (VZ_AppInfo info in VZ_AppHelper.GetInstance().appList) { Grid grid = new Grid(); grid.Margin = new Thickness(0, 40, 0, 40); Button bt = VZMethods.getNoBgImageButton(VZMethods.getImageContentByAbsolutePath(info.appImgPath)); bt.Margin = new Thickness(0); bt.Tag = counter++; bt.Click += Bt_Click; bt.ClickMode = ClickMode.Release; grid.Children.Add(bt); if (info.type.Equals("game")) { img = VZMethods.getImageContent(@"Res\game_bottom_bar.png"); img.VerticalAlignment = VerticalAlignment.Bottom; img.Margin = new Thickness(20, 0, 20, 0); grid.Children.Add(img); img = VZMethods.getImageContent(@"Res\game_tag.png"); img.VerticalAlignment = VerticalAlignment.Top; img.Width = 80; img.Height = 48; img.HorizontalAlignment = HorizontalAlignment.Right; img.Margin = new Thickness(0, 30, 60, 0); grid.Children.Add(img); StackPanel tmpSp = new StackPanel(); tmpSp.Orientation = Orientation.Horizontal; tmpSp.Height = 80; tmpSp.Background = new SolidColorBrush(Colors.Transparent); tmpSp.VerticalAlignment = VerticalAlignment.Bottom; grid.Children.Add(tmpSp); tb = new TextBlock(); tb.VerticalAlignment = VerticalAlignment.Bottom; tb.Margin = new Thickness(60, 0, 20, 20); tb.Foreground = new SolidColorBrush(Colors.White); tb.Opacity = 0.8; tb.FontSize = 25; tb.Text = info.appName; tmpSp.Children.Add(tb); for (int i = 0; i < info.tagList.Count; i++) { Grid tagGrid = new Grid(); tagGrid.Width = 60; tagGrid.Height = 34; tagGrid.Margin = new Thickness(0, 13, 10, 0); tagGrid.Background = new ImageBrush(VZMethods.getBitmap(@"pack://*****:*****@"Res\gaming.png"); img.VerticalAlignment = VerticalAlignment.Top; img.Width = 139; img.Height = 48; img.HorizontalAlignment = HorizontalAlignment.Right; img.Stretch = Stretch.None; img.Margin = new Thickness(0, 30, 60, 0); img.Name = "img_cover"; img.Visibility = Visibility.Hidden; grid.Children.Add(img); gameGrid.Add(grid); } //第四行 增加页码 vpp = new VZ_PagePoint(); Grid.SetRow(vpp, 3); vpp.Visibility = Visibility.Hidden; mainGrid.Children.Add(vpp); showPage(pageIndex); secondTimer = new System.Timers.Timer(1000); secondTimer.AutoReset = true; secondTimer.Elapsed += SecondTimer_Elapsed; secondTimer.Start(); this.Activate(); }