private async void pageRoot_Loaded(object sender, RoutedEventArgs e) { for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) { var b = new Button(); b.SetValue(Grid.RowProperty, i); b.SetValue(Grid.ColumnProperty, j); b.Tag = i * 9 + j; b.Click += play_Click; b.PointerPressed += (s, u) => play_Click(s, null); b.Margin = new Thickness(1); b.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; b.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; b.BorderThickness = new Thickness(0); b.Background = bgBrush; Field[i, j] = b; GameField.Children.Add(b); } var rs = ApplicationData.Current.RoamingSettings.Values; if (rs.ContainsKey("hiscore")) UpdateHighScore((int)rs["hiscore"]); var tosave = false; if (rs.ContainsKey("savedata")) if ((int)rs["force"] == 1) tosave = true; else tosave = await Question.Show("You have game saved from previous time. Do you want to continue or start from scratch?", "Lines", "Continue", "Restart"); logic = new GameLogic(); seed = logic.seed; logic.Appeared += logic_Appeared; logic.Disappeared += logic_Disappeared; logic.PointsChanged += logic_PointsChanged; logic.GameOver += logic_GameOver; if (tosave) logic.Load(rs["savedata"] as string); else { ApplicationData.Current.RoamingSettings.Values.Remove("savedata"); logic.Start(); } GameOn = true; }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { board = new Board(10, 10, 5); for (int x = 0; x < board.Width; ++x) cellGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40) }); for (int y = 0; y < board.Height; ++y) cellGrid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(40)}); for (int y = 0; y < board.Height; ++y) for (int x = 0; x < board.Width; ++x) { var button = new Button {Background = new SolidColorBrush(Colors.Purple), Content = " "}; button.SetValue(Grid.ColumnProperty, x); button.SetValue(Grid.RowProperty, y); button.Click += ButtonClick; cellGrid.Children.Add(button); } }
private void Tutorial_Loaded(object sender, RoutedEventArgs e) { for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) { var b = new Button(); b.SetValue(Grid.RowProperty, i); b.SetValue(Grid.ColumnProperty, j); b.Tag = i * 9 + j; b.Margin = new Thickness(1); b.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; b.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; b.BorderThickness = new Thickness(0); b.Background = bgBrush; Field[i, j] = b; GameField.Children.Add(b); } Stage1(); }
//Permet d'afficher les équipements dans la grille /// <summary> /// Cette méthode permet d'afficher tous les équipements enregistrés dans le Core (cf DLL) sous forme d'icônes dans une grille. \n /// Elle affiche la grille dans le layout passé en paramètre et l'affiche à la page demandée (pageActuelle). /// </summary> /// <param name="pageActuelle">Numéro de la page de la grille à afficher.</param> /// <param name="cadre">Layout dans lequel la grille sera créée.</param> /// <param name="core">Arbre (cf DLL) contenant les équipements à afficher.</param> /// <returns>Liste des boutons associés aux pièces.</returns> public List<Button> afficherEquipementsGrille(int pageActuelle, String nomPiece, Grid cadre, IntPtr core) { int format = Core_getIconSize(core); //format de la grille, 0: grande, 1: moyenne, 2: petite nbCases = creerGrille(cadre, format); //crée le bon nombre de "grid" selon le format et retourne le nb de cases IntPtr room = Core_getRoomByName(core,nomPiece); int nbEquip = Room_getNumberEquiments(room); List<Button> boutons = new List<Button>(); //Crée un bouton pour chaque équipement et l'affiche dans la grille for (int i = pageActuelle * nbCases; i < nbEquip && i < nbCases * (pageActuelle + 1); i++) { IntPtr equ = Room_getEquipmentByIndex(room, i); //équipement à afficher Button bouton = new Button(); //bouton associé a cet equipement bouton.BorderBrush = new SolidColorBrush(Colors.DarkSalmon); bouton.Tag = i; //tag qui permet de récuperer facilement l'indice de l'équipement bouton.SetValue(Button.HorizontalAlignmentProperty, HorizontalAlignment.Stretch); bouton.SetValue(Button.VerticalAlignmentProperty, VerticalAlignment.Stretch); //Affichage du nom de l'équipement dans la grille IntPtr tmp = Node_getName(equ); string nomEqu = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(tmp); TextBlock nomIcone = creerLabel(nomEqu); //Création image (icône de l'equipement) IntPtr iconeName = Node_getIco(equ); string nameIc = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(iconeName); Image image = creerImageIcone(nameIc, bouton); //Associe image et nom de l'équipement au bouton ajouterImageEtLabelAuBouton(image, nomIcone, bouton); //Place le bouton dans la grille if (i < pageActuelle * nbCases + nbCases / 2) { bouton.SetValue(Grid.ColumnProperty, i % nbCases); bouton.SetValue(Grid.RowProperty, 0); } else { bouton.SetValue(Grid.ColumnProperty, i % nbCases - nbCases / 2); bouton.SetValue(Grid.RowProperty, 1); } cadre.Children.Add(bouton); boutons.Add(bouton); } //nbRoom : nombre de pièces qu'il reste à afficher if (nbEquip - nbCases * pageActuelle < 0) { nbEquip = 0; } else { nbEquip = nbEquip - nbCases * pageActuelle; } //Complète la grille avec des boutons vides (sans pièce) for (int i = nbCases * pageActuelle + ((nbEquip % nbCases)); i < (nbCases * pageActuelle + nbCases); i++) { Button bouton = new Button(); bouton.BorderBrush = new SolidColorBrush(Colors.DarkSalmon); bouton.Tag = -1; bouton.SetValue(Button.HorizontalAlignmentProperty, HorizontalAlignment.Stretch); bouton.SetValue(Button.VerticalAlignmentProperty, VerticalAlignment.Stretch); //Place le bouton dans la grille if (i < (pageActuelle * nbCases + nbCases / 2)) { bouton.SetValue(Grid.ColumnProperty, i % nbCases); bouton.SetValue(Grid.RowProperty, 0); } else { bouton.SetValue(Grid.ColumnProperty, i % nbCases - nbCases / 2); bouton.SetValue(Grid.RowProperty, 1); } cadre.Children.Add(bouton); } return boutons; }
private void InsertOrders(OrderType type) { orderGrid.Children.Clear(); orderGrid.RowDefinitions.Clear(); orderGrid.ColumnDefinitions.Clear(); List<OrderInfo> orders = null; switch(type) { case OrderType.NOT_PAY: orders = notPayOrders; break; case OrderType.PAYED: orders = payedOrders; break; case OrderType.COMPLETED: orders = completedOrders; break; default: break; } if(null == orders) { return; } int count = orders.Count; for(int i=0; i<count; i++) { RowDefinition row = new RowDefinition(); //row.Height = new GridLength(orderGridSizeInfo.orderGridHeight); orderGrid.RowDefinitions.Add(row); } int nRow = 0; foreach(var item in orders) { Grid oneOrderGrid = new Grid(); oneOrderGrid.Background = new SolidColorBrush(Color.FromArgb(255,235,235,235)); //Init four panels RelativePanel topPanel = new RelativePanel(); topPanel.Background = new SolidColorBrush(Color.FromArgb(255,241,241,241)); topPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin; topPanel.Width = infoPanel.Width; Grid.SetColumn(topPanel, 0); Grid.SetRow(topPanel, 0); oneOrderGrid.Children.Add(topPanel); RelativePanel addressPanel = new RelativePanel(); addressPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin; addressPanel.Width = infoPanel.Width; addressPanel.Background = new SolidColorBrush(Color.FromArgb(255, 241, 241, 241)); Grid.SetColumn(addressPanel, 0); Grid.SetRow(addressPanel, 2); oneOrderGrid.Children.Add(addressPanel); //goods panel RelativePanel goodsGridPanel = new RelativePanel(); goodsGridPanel.Background = new SolidColorBrush(Color.FromArgb(255, 235, 235, 235)); //goodsGridPanel.Width = infoPanel.Width; goodsGridPanel.Height = orderGridSizeInfo.goodsPicHeight + 4 * orderGridSizeInfo.margin + orderGridSizeInfo.infoPanelHeight*2; //SlidePanel slidePanel = new SlidePanel(infoPanel.Width); //slidePanel.Add(goodsGridPanel,orderGridSizeInfo.goodsPicWidth); //Grid.SetColumn(slidePanel, 0); //Grid.SetRow(slidePanel, 1); //oneOrderGrid.Children.Add(slidePanel); //Grid.SetColumn(goodsGridPanel, 0); //Grid.SetRow(goodsGridPanel, 1); //oneOrderGrid.Children.Add(goodsGridPanel); RelativePanel buttonPanel = new RelativePanel(); buttonPanel.Background = new SolidColorBrush(Color.FromArgb(255, 241, 241, 241)); buttonPanel.Width = infoPanel.Width; buttonPanel.Height = orderGridSizeInfo.infoPanelHeight + orderGridSizeInfo.margin*2; Grid.SetColumn(buttonPanel, 0); Grid.SetRow(buttonPanel, 3); buttonPanel.VerticalAlignment = VerticalAlignment.Top; oneOrderGrid.Children.Add(buttonPanel); RowDefinition topRow = new RowDefinition(); topRow.Height = new GridLength(topPanel.Height); oneOrderGrid.RowDefinitions.Add(topRow); RowDefinition goodsGridRow = new RowDefinition(); goodsGridRow.Height = new GridLength(goodsGridPanel.Height); oneOrderGrid.RowDefinitions.Add(goodsGridRow); RowDefinition addressRow = new RowDefinition(); addressRow.Height = new GridLength(addressPanel.Height); oneOrderGrid.RowDefinitions.Add(addressRow); RowDefinition buttonRow = new RowDefinition(); buttonRow.Height = new GridLength(buttonPanel.Height + orderGridSizeInfo.margin); oneOrderGrid.RowDefinitions.Add(buttonRow); #region order info panel items TextBlock topLeft = new TextBlock(); topLeft.Width = 80; topLeft.Height = orderGridSizeInfo.infoPanelHeight; topLeft.Text = "订单号"; topLeft.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51)); topLeft.Margin = new Thickness(20, 0, 0, 0); topLeft.SetValue(RelativePanel.AlignLeftWithPanelProperty,true); topLeft.SetValue(RelativePanel.AlignBottomWithPanelProperty, true); topPanel.Children.Add(topLeft); TextBlock topRight = new TextBlock(); topRight.Width = 150; topRight.Height = orderGridSizeInfo.infoPanelHeight; topRight.Text = item.id; topRight.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51)); topRight.Margin = new Thickness(0, 0, 20, 0); topRight.SetValue(RelativePanel.AlignRightWithPanelProperty, true); topRight.SetValue(RelativePanel.AlignBottomWithPanelProperty, true); topRight.TextAlignment = TextAlignment.Right; topPanel.Children.Add(topRight); #endregion #region address panel item TextBlock addressLeft = new TextBlock(); addressLeft.Width = topPanel.Width / 2; addressLeft.Height = orderGridSizeInfo.infoPanelHeight; addressLeft.Margin = new Thickness(20,0,0,0); addressLeft.Text = "配送地址"; addressLeft.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51)); addressLeft.SetValue(RelativePanel.AlignLeftWithPanelProperty, true); addressLeft.SetValue(RelativePanel.AlignBottomWithPanelProperty, true); addressPanel.Children.Add(addressLeft); TextBlock addressRight = new TextBlock(); addressRight.Width = 150; addressRight.Height = orderGridSizeInfo.infoPanelHeight; addressRight.Text = item.address; addressRight.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51)); addressRight.Margin = new Thickness(0,0,20,0); addressRight.TextAlignment = TextAlignment.Right; addressRight.SetValue(RelativePanel.AlignRightWithPanelProperty, true); addressRight.SetValue(RelativePanel.AlignBottomWithPanelProperty, true); addressPanel.Children.Add(addressRight); #endregion #region button panel item TextBlock priceText = new TextBlock(); priceText.Width = 12; priceText.Height = 20; priceText.Text = "¥"; priceText.Name = "priceText"; priceText.Foreground = new SolidColorBrush(Color.FromArgb(255,253,40,3)); priceText.TextAlignment = TextAlignment.Left; priceText.SetValue(RelativePanel.AlignLeftWithPanelProperty, true); priceText.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true); priceText.Margin = new Thickness(17, 0, 0, -32); buttonPanel.Children.Add(priceText); TextBlock priceNumberText = new TextBlock(); priceNumberText.Width = 70; priceNumberText.Height = orderGridSizeInfo.infoPanelHeight; priceNumberText.Text = item.price; priceNumberText.Foreground = new SolidColorBrush(Colors.Red); priceNumberText.FontSize = 20; priceNumberText.TextAlignment = TextAlignment.Left; priceNumberText.SetValue(RelativePanel.RightOfProperty, "priceText"); priceNumberText.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true); priceNumberText.Margin = new Thickness(3, 0, 0, 0); buttonPanel.Children.Add(priceNumberText); Button btnPay = new Button(); if (item.payed.Equals("true")) { btnPay.Visibility = Visibility.Collapsed; } btnPay.Width = 100; btnPay.Height = orderGridSizeInfo.infoPanelHeight; btnPay.VerticalContentAlignment = VerticalAlignment.Center; btnPay.HorizontalContentAlignment = HorizontalAlignment.Center; btnPay.BorderThickness = new Thickness(0); btnPay.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 78, 0)); btnPay.Name = "btnPay"; TextBlock btnPayText = new TextBlock(); btnPayText.Text = "进行付款"; btnPayText.Foreground = new SolidColorBrush(Colors.White); btnPay.Content = btnPayText; //btnPay.Foreground = new SolidColorBrush(Colors.White); btnPay.Background = new SolidColorBrush(Color.FromArgb(255,255,78,0)); btnPay.SetValue(RelativePanel.AlignRightWithPanelProperty,true); btnPay.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true); btnPay.Margin = new Thickness(0, 0, 20, 0); buttonPanel.Children.Add(btnPay); Button btnCancel = new Button(); btnCancel.Width = 100; btnCancel.Height = orderGridSizeInfo.infoPanelHeight; btnCancel.VerticalContentAlignment = VerticalAlignment.Center; btnCancel.HorizontalContentAlignment = HorizontalAlignment.Center; //btnCancel.Content = "取消订单"; TextBlock btnCancelText = new TextBlock(); btnCancelText.Text = "取消订单"; btnCancelText.Foreground = new SolidColorBrush(Colors.White); btnCancel.Content = btnCancelText; btnCancel.BorderThickness = new Thickness(0); btnCancel.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 148, 148, 148)); //btnCancel.Foreground = new SolidColorBrush(Colors.White); btnCancel.Background = new SolidColorBrush(Color.FromArgb(255,148,148,148)); btnCancel.Margin = new Thickness(0, 0, 5, 0); btnCancel.SetValue(RelativePanel.LeftOfProperty, "btnPay"); btnCancel.SetValue(RelativePanel.AlignHorizontalCenterWithPanelProperty, true); buttonPanel.Children.Add(btnCancel); #endregion #region goods detail panel item int goodsCount = item.goodsList.Count; double goodsGridPanelWidth = 0; for(int i=0; i< goodsCount; i++) { RelativePanel goodsItemPanel = new RelativePanel(); goodsItemPanel.Background = new SolidColorBrush(Color.FromArgb(255,224,224,224)); goodsItemPanel.SetValue(RelativePanel.AlignLeftWithPanelProperty,true); goodsItemPanel.Margin = new Thickness(goodsGridPanelWidth + orderGridSizeInfo.margin,0,0,0); //goods name TextBlock goodsNameText = new TextBlock(); goodsNameText.Width = 60; goodsNameText.Height = orderGridSizeInfo.infoPanelHeight - 5; goodsNameText.Text = item.goodsList[i].name; goodsNameText.TextAlignment = TextAlignment.Left; goodsNameText.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51)); goodsNameText.SetValue(RelativePanel.AlignLeftWithPanelProperty,true); goodsNameText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true); goodsNameText.Margin = new Thickness(orderGridSizeInfo.margin,0,0,orderGridSizeInfo.margin); goodsItemPanel.Children.Add(goodsNameText); //goods number TextBlock numberText = new TextBlock(); numberText.Height = orderGridSizeInfo.infoPanelHeight - 5; numberText.Width = 25; numberText.Name = "number"; numberText.TextAlignment = TextAlignment.Right; numberText.Foreground = new SolidColorBrush(Color.FromArgb(255,51,51,51)); numberText.Text = "x" + Convert.ToString(item.goodsList[i].count); numberText.SetValue(RelativePanel.AlignRightWithPanelProperty,true); numberText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true); numberText.Margin = new Thickness(0,0, orderGridSizeInfo.margin, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(numberText); //goods price TextBlock singlePriceText = new TextBlock(); singlePriceText.Height = orderGridSizeInfo.infoPanelHeight; singlePriceText.Width = 30; singlePriceText.Name = "singlePriceText"; singlePriceText.TextAlignment = TextAlignment.Left; singlePriceText.FontSize = 20; singlePriceText.Foreground = new SolidColorBrush(Color.FromArgb(255, 253, 40, 3)); singlePriceText.Text = item.goodsList[i].price; singlePriceText.SetValue(RelativePanel.AlignBottomWithPanelProperty,true); singlePriceText.SetValue(RelativePanel.LeftOfProperty, "number"); singlePriceText.Margin = new Thickness(0,0,0, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(singlePriceText); TextBlock priceSymbol = new TextBlock(); priceSymbol.Height = orderGridSizeInfo.infoPanelHeight - 5; priceSymbol.Width = 20; priceSymbol.TextAlignment = TextAlignment.Right; priceSymbol.FontSize = 16; priceSymbol.Foreground = new SolidColorBrush(Color.FromArgb(255, 253, 40, 3)); priceSymbol.Text = "¥"; priceSymbol.SetValue(RelativePanel.AlignBottomWithPanelProperty,true); priceSymbol.SetValue(RelativePanel.LeftOfProperty, "singlePriceText"); priceSymbol.Margin = new Thickness(0, 0, 0, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(priceSymbol); //pictrue name TextBlock picNameText = new TextBlock(); picNameText.Name = "picNameText"; picNameText.Height = orderGridSizeInfo.infoPanelHeight; picNameText.Width = orderGridSizeInfo.goodsPicWidth; picNameText.Text = item.goodsList[i].imageName; picNameText.TextAlignment = TextAlignment.Left; picNameText.Foreground = new SolidColorBrush(Color.FromArgb(255, 51, 51, 51)); picNameText.FontSize = 18; picNameText.SetValue(RelativePanel.AlignLeftWithPanelProperty,true); picNameText.SetValue(RelativePanel.AboveProperty, "singlePriceText"); picNameText.Margin = new Thickness(orderGridSizeInfo.margin, 0, 0, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(picNameText); //goods picture Grid picGrid = new Grid(); RowDefinition row = new RowDefinition(); row.Height = new GridLength(orderGridSizeInfo.goodsPicHeight); ColumnDefinition col = new ColumnDefinition(); col.Width = new GridLength(orderGridSizeInfo.goodsPicWidth); picGrid.RowDefinitions.Add(row); picGrid.ColumnDefinitions.Add(col); Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.White); border.BorderThickness = new Thickness(1); border.CornerRadius = new CornerRadius(3, 3, 3, 3); border.Background = item.goodsList[i].brush; picGrid.Children.Add(border); picGrid.SetValue(RelativePanel.AlignLeftWithPanelProperty, true); picGrid.SetValue(RelativePanel.AlignRightWithPanelProperty,true); picGrid.SetValue(RelativePanel.AlignTopWithPanelProperty,true); picGrid.SetValue(RelativePanel.AboveProperty, "picNameText"); picGrid.Margin = new Thickness(orderGridSizeInfo.margin, orderGridSizeInfo.margin, orderGridSizeInfo.margin, orderGridSizeInfo.margin); goodsItemPanel.Children.Add(picGrid); goodsGridPanelWidth += (orderGridSizeInfo.goodsPicWidth + 3*orderGridSizeInfo.margin); goodsGridPanel.Children.Add(goodsItemPanel); } SlidePanel slidePanel = new SlidePanel(infoPanel.Width); goodsGridPanel.Width = goodsGridPanelWidth; slidePanel.Add(goodsGridPanel, orderGridSizeInfo.goodsPicWidth + orderGridSizeInfo.margin); Grid.SetColumn(slidePanel, 0); Grid.SetRow(slidePanel, 1); oneOrderGrid.Children.Add(slidePanel); #endregion Grid.SetColumn(oneOrderGrid, 0); Grid.SetRow(oneOrderGrid, nRow); orderGrid.Children.Add(oneOrderGrid); nRow++; } }
void Add(int i, int j, int c, Action<Button> action) { var b = new Button(); b.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 127, 127, 146)); b.Background = Colors[c]; b.Style = Application.Current.Resources["RoundButton"] as Style; b.Margin = new Thickness(1); b.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; b.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; b.Tag = 1; b.SetValue(Grid.RowProperty, i); b.SetValue(Grid.ColumnProperty, j); b.Click += (s, e) => action(s as Button); GameField.Children.Add(b); Balls[i,j] = b; Field[i,j].Visibility = Visibility.Collapsed; }
private async void InitializeLevel(int level) { var finished = await CheckEndReached(); if (finished) return; level = CurrentLevel; Count = GameTable[level]; CurrentLives = Lives[level]; Cleaned = false; Opened = 0; var crc = Circle.GeneratePoints(Count, (int)ContentPanel.RenderSize.Width, (int) ContentPanel.RenderSize.Height); int num = 0; if (Difficulty < 5) GenerateTags(Count, seed.Next(0, 2) == 0 ? TagType.Digit : TagType.Letter, Difficulty > 2); else GenerateTags(Count, TagType.Any, Difficulty == 6); RefillSequence(); UpdateSeqView(); foreach (var bc in ContentPanel.Children) if (bc.GetType() == typeof(Button)) { ((Button)bc).Click -= PlayTapped_Click; } ContentPanel.Children.Clear(); foreach (var c in crc) { var b = new Button(); b.BorderThickness = new Thickness(9); b.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, (byte)seed.Next(160, 240), (byte)seed.Next(160, 240), (byte)seed.Next(160, 240))); b.FontFamily = new FontFamily("Georgia"); b.FontWeight = FontWeights.SemiBold; b.FontSize = 60; b.SetValue(Canvas.LeftProperty, c.X - 60); b.SetValue(Canvas.TopProperty, c.Y - 60); b.Width = b.Height = 2 * c.Radius; b.Style = Application.Current.Resources["RoundButton"] as Style; b.Content = b.Tag = Tags[num++]; b.Click += PlayTapped_Click; ContentPanel.Children.Add(b); } WaitForIt(); }
private void GenerateGameField() { for (int i = 0; i < this.g.FieldSize; i++) { GameField.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.0, GridUnitType.Star) }); } for (int i = 0; i < g.FieldSize; i++) { GameField.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1.0, GridUnitType.Star) }); } for (int i = 0; i < GameField.RowDefinitions.Count; i++) { for (int j = 0; j < GameField.ColumnDefinitions.Count; j++) { Button btn = new Button(); btn.SetValue(Grid.RowProperty, i); btn.SetValue(Grid.ColumnProperty, j); btn.Content = Char.ToUpper(g.LetterMatrix[i, j]); btn.Click += btnGameFiels_Click; switch (g.CheckMatrix[i, j]) { case 2: SetButtonWithLetterAppearance(btn); break; case 1: SetButtonCanInputAppearance(btn); break; case 0: SetButtonCantInputAppearance(btn); break; } GameField.Children.Add(btn); } } }
//Генерация панели с алфавитом private void GenerateAlphabet() { for (int i = 0; i < 4; i++) { Alphabet.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.0, GridUnitType.Star) }); } for (int j = 0; j < 8; j++) { Alphabet.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1.0, GridUnitType.Star) }); } for (int i = 0; i < Alphabet.RowDefinitions.Count; i++) { for (int j = 0; j < Alphabet.ColumnDefinitions.Count; j++) { Button btn = new Button(); btn.SetValue(Grid.RowProperty, i); btn.SetValue(Grid.ColumnProperty, j); btn.HorizontalAlignment = HorizontalAlignment.Stretch; btn.VerticalAlignment = VerticalAlignment.Stretch; btn.Content = g.Alphabet[i,j]; btn.Click += btnAlphabet_Click; Alphabet.Children.Add(btn); } } }
void logic_Appeared(object sender, IntPoint e) { var b = new Button(); b.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 127, 127, 146)); b.Background = Colors[e.Data-1]; b.Style = Application.Current.Resources["RoundButton"] as Style; b.Margin = new Thickness(1); b.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch; b.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch; b.Tag = new Tuple<int, int>(e.X, e.Y); b.SetValue(Grid.RowProperty, e.X); b.SetValue(Grid.ColumnProperty, e.Y); b.Click += (s, u) => SelectBall((s as Button).Tag as Tuple<int, int>); GameField.Children.Add(b); Balls[e.X, e.Y] = b; Field[e.X, e.Y].Visibility = Visibility.Collapsed; if (GameOn) ApplicationData.Current.RoamingSettings.Values["savedata"] = logic.Save(); }
void MyMap_ViewBoundsChanged(object sender, ViewBoundsEventArgs e) { #region Ellipse Ellipse myellipse = new Ellipse(); myellipse.Fill = new SolidColorBrush(Colors.Red); Rectangle2D ellbounds = new Rectangle2D(119.5, 21, 122.5, 26); this.elementsLayer.AddChild(myellipse, ellbounds); MyEllipseStory.Stop(); Storyboard.SetTarget(myDoubleAnimation, myellipse); MyEllipseStory.Begin(); #endregion #region Pushpin Pushpin beijing = new Pushpin(); beijing.Location = new Point2D(116.2, 39.6); this.elementsLayer.AddChild(beijing); Pushpin ulanBator = new Pushpin(); ulanBator.Location = new Point2D(106.5, 47.6); ulanBator.Background = new SolidColorBrush(Colors.Blue); this.elementsLayer.AddChild(ulanBator); Pushpin moscow = new Pushpin(); moscow.Location = new Point2D(37.4, 55.5); moscow.Background = new SolidColorBrush(Colors.Yellow); this.elementsLayer.AddChild(moscow); Pushpin prague = new Pushpin(); prague.Location = new Point2D(14.3, 50.1); prague.Background = new SolidColorBrush(Colors.Orange); this.elementsLayer.AddChild(prague); Pushpin berlin = new Pushpin(); berlin.Location = new Point2D(13.3, 52.3); berlin.Background = new SolidColorBrush(Colors.Purple); this.elementsLayer.AddChild(berlin); #endregion #region Polylinebase PolygonElement line = new PolygonElement(); line.Stroke = new SolidColorBrush(Colors.Yellow); line.StrokeThickness = 3; line.Opacity = 1; line.StrokeDashArray = new DoubleCollection { 3, 3 }; line.StrokeEndLineCap = PenLineCap.Triangle; Point2DCollection points = new Point2DCollection(); points.Add(new Point2D(121.3, 25)); points.Add(new Point2D(116.2, 39.6)); points.Add(new Point2D(106.5, 47.6)); points.Add(new Point2D(37.4, 55.5)); points.Add(new Point2D(14.3, 50.1)); points.Add(new Point2D(13.3, 52.3)); points.Add(new Point2D(0.1, 51.3)); line.Point2Ds = points; this.elementsLayer.AddChild(line); #endregion #region PolygonElement PolygonElement polygon = new PolygonElement(); polygon.Stroke = new SolidColorBrush(Colors.Purple); polygon.Opacity = 0.5; polygon.Fill = this.British; Point2DCollection gonpoints = new Point2DCollection(); gonpoints.Add(new Point2D(-8, 61)); gonpoints.Add(new Point2D(-6, 55)); gonpoints.Add(new Point2D(-8, 50)); gonpoints.Add(new Point2D(2, 50)); gonpoints.Add(new Point2D(1, 61)); polygon.Point2Ds = gonpoints; this.elementsLayer.AddChild(polygon); #endregion #region Button Button btn = new Button(); btn.Content = "点击"; Brush btnbackground = new SolidColorBrush(Colors.Blue); btn.SetValue(Button.BackgroundProperty, btnbackground); btn.Click += new RoutedEventHandler(btn_Click); Rectangle2D btnbounds = new Rectangle2D(95, 29, 115, 43); btn.SetValue(ElementsLayer.BBoxProperty, btnbounds); this.elementsLayer.AddChild(btn); #endregion MyMap.ViewBoundsChanged -= MyMap_ViewBoundsChanged; }