Exemplo n.º 1
0
        private void DrawElement(DrawingContext dc,
                                 PointI element, Brush brush, int distance)
        {
            // translate origin to center of current polygon
            PolygonGridTest dialog = PolygonGridTest.Instance;
            PointD          center = dialog.Grid.GridToDisplay(element);

            dc.PushTransform(new TranslateTransform(center.X, center.Y));

            // draw inset polygon with specified brush
            if (brush != null)
            {
                dc.DrawGeometry(brush, new Pen(Brushes.Black, 1), dialog.InsetGeometry);
            }

            // draw distance if desired
            if (distance > 0)
            {
                Typeface typeface = dialog.FontFamily.GetTypefaces().ElementAt(0);

                FormattedText text = new FormattedText(distance.ToString(),
                                                       CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight,
                                                       typeface, dialog.FontSize, Brushes.Black);

                dc.DrawText(text, new Point(-text.Width / 2.0, -text.Height / 2.0));
            }

            dc.Pop();
        }
Exemplo n.º 2
0
        private void PolygonGridCommandExecuted(object sender, ExecutedRoutedEventArgs args)
        {
            args.Handled = true;
            Window dialog = new PolygonGridTest()
            {
                Owner = this
            };

            dialog.ShowDialog();
        }