当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.SetValue方法代码示例

本文整理汇总了C#中Canvas.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.SetValue方法的具体用法?C# Canvas.SetValue怎么用?C# Canvas.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Canvas的用法示例。


在下文中一共展示了Canvas.SetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: add

 private void add(ref Grid grid, int row, int column)
 {
     Canvas canvas = new Canvas();
     canvas.Height = 80;
     canvas.Width = 80;
     canvas.Background = Background;
     canvas.Tapped += (object sender, TappedRoutedEventArgs e) =>
     {
         if (!won)
         {
             canvas = ((Canvas)(sender));
             if ((canvas.Children.Count < 1))
             {
                 canvas.Children.Add(getPiece());
                 board[(int)canvas.GetValue(Grid.RowProperty), (int)canvas.GetValue(Grid.ColumnProperty)] = piece;
             }
             if (winner())
             {
                 won = true;
                 Show((piece + " wins!"), "Noughts and Crosses");
             }
             else if (drawn())
             {
                 Show("Draw!", "Noughts and Crosses");
             }
             else
             {
                 piece = ((piece == cross) ? nought : cross);
             }
         }
     };
     canvas.SetValue(Grid.ColumnProperty, column);
     canvas.SetValue(Grid.RowProperty, row);
     grid.Children.Add(canvas);
 }
开发者ID:vvzwvv,项目名称:UWPTutorials,代码行数:35,代码来源:Library.cs

示例2: add

 private void add(ref Grid grid, int row, int column)
 {
     Canvas canvas = new Canvas();
     canvas.Height = 46;
     canvas.Width = 46;
     canvas.Background = Background;
     canvas.Tapped += (object sender, TappedRoutedEventArgs e) =>
     {
         if (!won)
         {
             int selected;
             canvas = ((Canvas)(sender));
             row = (int)canvas.GetValue(Grid.RowProperty);
             column = (int)canvas.GetValue(Grid.ColumnProperty);
             selected = board[row, column];
             if (canvas.Children.Count <= 0)
             {
                 canvas.Children.Clear();
                 canvas.Children.Add(getPiece(values[selected]));
                 if (selected == hit)
                 {
                     hits++;
                 }
                 else if (selected == miss)
                 {
                     misses++;
                 }
                 moves++;
             }
             if (moves < (size * size) && misses < score)
             {
                 if (hits == score)
                 {
                     Show("Well Done! You scored " + hits + " hits and " + misses + " misses!", "Hit or Miss");
                     won = true;
                 }
             }
             else
             {
                 Show("Game Over! You scored " + hits + " hits and " + misses + " misses!", "Hit or Miss");
                 won = true;
             }
         }
     };
     canvas.SetValue(Grid.ColumnProperty, column);
     canvas.SetValue(Grid.RowProperty, row);
     grid.Children.Add(canvas);
 }
开发者ID:RoguePlanetoid,项目名称:Windows-10-Universal-Windows-Platform,代码行数:48,代码来源:Library.cs

示例3: add

 private void add(Grid grid, int row, int column)
 {
     Canvas canvas = new Canvas();
     canvas.Height = 40;
     canvas.Width = 40;
     canvas.Background = Background;
     canvas.Tapped += (object sender, TappedRoutedEventArgs e) =>
     {
         if (!won)
         {
             canvas = ((Canvas)(sender));
             row = (int)canvas.GetValue(Grid.RowProperty);
             column = (int)canvas.GetValue(Grid.ColumnProperty);
             if (board[column, 0] == 0) // Check Free Row
             {
                 place(grid, column, row);
             }
         }
         else
         {
             Show("Game Over!", "Four in Row");
         }
     };
     canvas.SetValue(Grid.ColumnProperty, column);
     canvas.SetValue(Grid.RowProperty, row);
     grid.Children.Add(canvas);
 }
开发者ID:RoguePlanetoid,项目名称:Windows-10-Universal-Windows-Platform,代码行数:27,代码来源:Library.cs

示例4: add

 private void add(Grid grid, int row, int column)
 {
     Canvas canvas = new Canvas();
     canvas.Height = 40;
     canvas.Width = 40;
     canvas.Background = new SolidColorBrush(lightOn);
     canvas.Tapped += (object sender, TappedRoutedEventArgs e) =>
     {
         if (!won)
         {
             canvas = ((Canvas)(sender));
             row = (int)canvas.GetValue(Grid.RowProperty);
             column = (int)canvas.GetValue(Grid.ColumnProperty);
             toggle(grid, row, column);
             if (row > 0)
             {
                 toggle(grid, row - 1, column); // Toggle Left
             }
             if (row < (size - 1))
             {
                 toggle(grid, row + 1, column); // Toggle Right
             }
             if (column > 0)
             {
                 toggle(grid, row, column - 1); // Toggle Above
             }
             if (column < (size - 1))
             {
                 toggle(grid, row, column + 1); // Toggle Below
             }
             moves++;
             if (winner())
             {
                 Show("Well Done! You won in " + moves + " moves!", "Light Game");
                 won = true;
             }
         }
     };
     canvas.SetValue(Grid.ColumnProperty, column);
     canvas.SetValue(Grid.RowProperty, row);
     grid.Children.Add(canvas);
 }
开发者ID:RoguePlanetoid,项目名称:Windows-10-Universal-Windows-Platform,代码行数:42,代码来源:Library.cs


注:本文中的Canvas.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。