예제 #1
0
        private void AddDigit(Coords coords, int value, bool isInitialValue)
        {
            var digitColour = isInitialValue ? Colors.Red : Colors.Black;

            var textBlock = new TextBlock
            {
                Text = Convert.ToString(value),
                FontSize = 48,
                Foreground = new SolidColorBrush(digitColour),
                Opacity = isInitialValue ? 0.6 : 1.0,
                TextAlignment = TextAlignment.Center,
            };

            var border = new Border
            {
                Width = _sw,
                Height = _sh,
                Child = textBlock,
                Tag = new DigitTag(coords, isInitialValue),
            };

            Canvas.SetLeft(border, coords.Col * _sw + GridLineHalfThickness);
            Canvas.SetTop(border, coords.Row * _sh + GridLineHalfThickness);
            Canvas.Children.Add(border);
        }
예제 #2
0
 public void RemoveDigit(Coords coords)
 {
     Canvas.Children
         .OfType<FrameworkElement>()
         .Where(fe => fe.Tag is DigitTag)
         .Where(fe => ((DigitTag)fe.Tag).Coords.Equals(coords))
         .ToList()
         .ForEach(fe => Canvas.Children.Remove(fe));
 }
예제 #3
0
 public DigitTag(Coords coords, bool isInitialValue)
 {
     Coords = coords;
     IsInitialValue = isInitialValue;
 }
예제 #4
0
 public void AddDigit(Coords coords, int value)
 {
     AddDigit(coords, value, false);
 }
예제 #5
0
 private static IImmutableList<InternalRow> BuildInternalRowsForCell(Coords coords, InitialValue initialValue)
 {
     return initialValue != null
         ? ImmutableList.Create(new InternalRow(coords, initialValue.Value, true))
         : Digits.Select(value => new InternalRow(coords, value, false)).ToImmutableList();
 }