本文整理汇总了C#中Windows.UI.Xaml.Controls.Button.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetValue方法的具体用法?C# Button.SetValue怎么用?C# Button.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.UI.Xaml.Controls.Button
的用法示例。
在下文中一共展示了Button.SetValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: pageRoot_Loaded
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;
}
示例2: OnNavigatedTo
/// <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);
}
}
示例3: Tutorial_Loaded
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();
}
示例4: afficherEquipementsGrille
//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;
}
示例5: InsertOrders
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);
//.........这里部分代码省略.........
示例6: Add
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;
}
示例7: InitializeLevel
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();
}
示例8: GenerateGameField
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);
}
}
}
示例9: GenerateAlphabet
//Генерация панели с алфавитом
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);
}
}
}
示例10: logic_Appeared
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();
}
示例11: MyMap_ViewBoundsChanged
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;
}