internal bool Draw(Graphics graphics, Platelet platelet, Point mousePosition) { var x = _positions.OrderBy(p => { #warning name to long return(p.CalculateMinimumInnerCornerDistance(mousePosition)); }); var best = x.FirstOrDefault(); return(platelet.Draw(graphics, best)); }
public bool PlaceAt(Platelet platelet, Point position) { var x = _positions.OrderBy(p => { #warning name to long return(p.CalculateMinimumInnerCornerDistance(position)); }); var best = x.FirstOrDefault(); if (best != null) { return(platelet.Place(best)); } return(false); }
public GameForm() { PictureBox pb = new PictureBox { SizeMode = PictureBoxSizeMode.Zoom, Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left, Location = new Point(0, 0), Size = this.ClientSize, BackColor = Color.Black, Image = new Bitmap(760 * 4, 660 * 5) }; var p = new Platelet(); using var g = Graphics.FromImage(pb.Image); g.FillRectangle(Brushes.Black, 0, 0, pb.Width, pb.Height); var positioningHelper = new PositioningHelper(pb.Image.Size); for (int fieldIndex = 0; fieldIndex < 19; fieldIndex++) { positioningHelper.Draw(g, p, fieldIndex); } this.Controls.Add(pb); var stringPlatelets = Properties.Resources.Platelets.Split(Environment.NewLine); foreach (var platelet in stringPlatelets) { var values = platelet.Split(';'); var leftValue = (PlateletValue)Int32.Parse(values[0]); var centerValue = (PlateletValue)Int32.Parse(values[1]); var rightValue = (PlateletValue)Int32.Parse(values[2]); var plateletObject = new Platelet(leftValue, centerValue, rightValue); _platelets.Add(plateletObject); } _platelets.Shuffle(); pb.MouseMove += (sender, e) => ((Control)sender).Invalidate(); pb.Paint += PaintPlatelets; pb.MouseClick += Place; //Cursor.Hide(); }
public bool PlaceAt(Platelet platelet, int fieldIndex) { return(platelet.Place(_positions[fieldIndex])); }
public bool Draw(Graphics g, Platelet platelet, int fieldIndex) { return(platelet.Draw(g, _positions[fieldIndex])); }