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); }
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)); }
public DigitTag(Coords coords, bool isInitialValue) { Coords = coords; IsInitialValue = isInitialValue; }
public void AddDigit(Coords coords, int value) { AddDigit(coords, value, false); }
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(); }