public void Execute(IList <Dot> dots) { Point screeSize = MainWindow.GetDrawableSize(); var image = new Bitmap(screeSize.X, screeSize.Y); using (Graphics g = Graphics.FromImage(image)) { g.Clear(Color.White); foreach (Dot dot in dots) { g.FillEllipse(RandomColors.GetBrush(dot.C), dot.X - DOT_RADIUS, dot.Y - DOT_RADIUS, 2 * DOT_RADIUS, 2 * DOT_RADIUS); } } MainWindow.ImageBox = image; }
private void DrawText(Graphics g, Cluster cluster) { GraphicsPath myPath = new GraphicsPath(); string stringText = $"{cluster.Number}"; FontFamily family = new FontFamily("Arial"); int fontStyle = (int)FontStyle.Regular; int emSize = (int)cluster.Radius / 2; Point origin = new Point(cluster.RadiusDot.X - emSize * stringText.Length / 3, cluster.RadiusDot.Y - emSize / 2); StringFormat format = StringFormat.GenericDefault; myPath.AddString(stringText, family, fontStyle, emSize, origin, format); g.SmoothingMode = SmoothingMode.AntiAlias; g.FillPath(RandomColors.GetBrush(cluster.Number), myPath); //g.DrawPath(new Pen(Brushes.Black,2), myPath); }