本文整理汇总了C#中Canvas.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.GetValue方法的具体用法?C# Canvas.GetValue怎么用?C# Canvas.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.GetValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}