public void AddDot(Coords coords, DotColour dotColour) { var aw = ActualWidth; var ah = ActualHeight; var sw = (aw - GridLineThickness) / GridSize; var sh = (ah - GridLineThickness) / GridSize; var dot = new Ellipse { Tag = TagType.Dot, Width = sw * 6 / 8, Height = sh * 6 / 8, Fill = new SolidColorBrush(dotColour.ToWpfColour()) }; var cellRect = new Rect(coords.X * sw + GridLineHalfThickness, (GridSize - coords.Y - 1) * sh + GridLineHalfThickness, sw, sh); cellRect.Inflate(-sw / 8, -sh / 8); Canvas.SetLeft(dot, cellRect.Left); Canvas.SetTop(dot, cellRect.Top); BoardCanvas.Children.Add(dot); _coordsToDots.Add(coords, dot); }
public static Color ToWpfColour(this DotColour dotColour) { var colourName = dotColour.ColourName; var colourNameWithNoSpaces = colourName.Replace(" ", ""); var propertyInfo = typeof(Colors).GetProperty(colourNameWithNoSpaces, BindingFlags.Public | BindingFlags.Static); if (propertyInfo != null) { var colour = (Color)propertyInfo.GetValue(null, BindingFlags.Public | BindingFlags.Static, null, new object[] {}, null); return(colour); } throw new InvalidOperationException(string.Format("Unknown colour name, \"{0}\".", colourName)); }
private void AddDot(Coords coords, DotColour dotColour) { _boardControl.AddDot(coords, dotColour); _coordsToDots.Add(coords, dotColour); BoardControlHasChanged(); }
public ColourPair(Coords startCoords, Coords endCoords, DotColour dotColour) { _startCoords = startCoords; _endCoords = endCoords; _dotColour = dotColour; }