private void GenerateAndAddPolygon()
        {
            if (SelectedPolygonGenerator == null)
            {
                throw new InvalidOperationException($"No polygon generator selected");
            }

            var polygon = SelectedPolygonGenerator.Generate(MaxSideLength);
            var color   = GenerateRandomColor();

            Polygons.Add(new Polygon
            {
                Points      = polygon,
                Description = $"Auto-generated Polygon at {DateTime.Now:D}",
                StrokeColor = color,
                FillColor   = Color.FromArgb(128, color)
            });
        }
예제 #2
0
        private void GenerateAndAddPolygon()
        {
            if (SelectedPolygonGenerator == null)
            {
                throw new InvalidOperationException($"No polygon generator selected");
            }

            var polygon = SelectedPolygonGenerator.Generate(MaxSideLength);
            var color   = GenerateRandomColor();

            Polygons.Add(new Polygon
            {
                Points      = polygon,
                Description = $"Auto-generated Polygon at {DateTime.Now:D}",
                StrokeColor = color,
                FillColor   = Color.FromArgb(128, color)
            });

            // This is how you would show a message box:
            // DialogHandler?.ShowMessageBox("Polygon has been added");
        }
예제 #3
0
        private async Task GenerateAndAddPolygonAsync()
        {
            if (SelectedPolygonGenerator == null)
            {
                throw new InvalidOperationException($"No polygon generator selected");
            }

            var polygon = SelectedPolygonGenerator.Generate(MaxSideLength);
            var color   = GenerateRandomColor();

            Polygons.Add(new Polygon
            {
                Points      = polygon,
                Description = $"Auto-generated Polygon at {DateTime.Now:D}",
                StrokeColor = color,
                FillColor   = Color.FromArgb(128, color)
            });

            if (DialogHandler != null)
            {
                await DialogHandler.ShowMessageBoxAsync("Polygon has been added");
            }
        }