private void DrawCross(DeskData deskData, PointData p, Brush color, double offset, double lineWidth) { double totalSize = (deskData.EndIndexY - deskData.StartIndexY) * deskData.SquareSize; Line line1 = new Line() { X1 = offset, X2 = deskData.SquareSize - offset, Y1 = offset, Y2 = deskData.SquareSize - offset }; Canvas.SetTop(line1, (p.Y + (-deskData.StartIndexY)) * deskData.SquareSize); Canvas.SetLeft(line1, (p.X + (-deskData.StartIndexX)) * deskData.SquareSize); line1.Stroke = color; line1.StrokeThickness = lineWidth; cnvDesk.Children.Add(line1); Line line2 = new Line() { X1 = offset, X2 = deskData.SquareSize - offset, Y2 = offset, Y1 = deskData.SquareSize - offset }; Canvas.SetTop(line2, (p.Y + (-deskData.StartIndexY)) * deskData.SquareSize); Canvas.SetLeft(line2, (p.X + (-deskData.StartIndexX)) * deskData.SquareSize); line2.Stroke = color; line2.StrokeThickness = lineWidth; cnvDesk.Children.Add(line2); }
private void SetSize(DeskData deskData) { int xColumns = deskData.EndIndexX - deskData.StartIndexX + 1; int yRows = deskData.EndIndexY - deskData.StartIndexY + 1; cnvDesk.Width = xColumns * deskData.SquareSize; cnvDesk.Height = yRows * deskData.SquareSize; }
public DeskData Copy() { DeskData copy = (DeskData)this.MemberwiseClone(); copy.CirclePoints = new List <PointData>(this.CirclePoints); copy.CrossPoints = new List <PointData>(this.CrossPoints); return(copy); }
private void DrawPoints(DeskData deskData) { double offset = deskData.SquareSize / 7; double lineWidth = deskData.SquareSize / 7; foreach (PointData p in deskData.CirclePoints) { DrawCircle(deskData, p, Brushes.Green, offset, lineWidth); } foreach (PointData p in deskData.CrossPoints) { DrawCross(deskData, p, Brushes.Red, offset, lineWidth); } }
private void DrawCircle(DeskData deskData, PointData p, Brush color, double offset, double lineWidth) { double totalSize = (deskData.EndIndexY - deskData.StartIndexY) * deskData.SquareSize; Ellipse elipse = new Ellipse() { Width = deskData.SquareSize - 2 * offset, Height = deskData.SquareSize - 2 * offset }; elipse.RenderTransform = new TranslateTransform(offset, offset); Canvas.SetTop(elipse, (p.Y + (-deskData.StartIndexY)) * deskData.SquareSize); Canvas.SetLeft(elipse, (p.X + (-deskData.StartIndexX)) * deskData.SquareSize); elipse.Stroke = color; elipse.StrokeThickness = lineWidth; cnvDesk.Children.Add(elipse); }
private void DrawGrid(DeskData deskData) { if (deskData == null) { return; } double width = cnvDesk.Width; double height = cnvDesk.Height; int xColumns = deskData.EndIndexX - deskData.StartIndexX + 1; int yRows = deskData.EndIndexY - deskData.StartIndexY + 1; Brush color = Brushes.Gray; double eps = 0.000001; double stepX = width / xColumns; for (double i = 0; i - eps <= width; i += stepX) { Line line = new Line() { X1 = i, Y1 = 0, X2 = i, Y2 = height }; line.Stroke = color; cnvDesk.Children.Add(line); } double stepY = height / yRows; for (double i = 0; i - eps <= height; i += stepY) { Line line = new Line() { X1 = 0, Y1 = i, X2 = width, Y2 = i }; line.Stroke = color; cnvDesk.Children.Add(line); } }
private void DisplayInfo(DeskData deskData) { tbTurn.Text = deskData.IsMyTurn ? "My turn" : "Oponent's turn"; tbMySymbol.Text = deskData.MySymbol == ESymbol.Circle ? "Circle" : "Cross"; tbWinner.Text = deskData.Winner; }