public static void WindingModeOutline(this GraphicsPath graphicsPath)
        {
            IntPtr    handle = (IntPtr)graphicsPath.GetType().GetField("nativePath", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(graphicsPath);
            HandleRef path   = new HandleRef(graphicsPath, handle);

            NativeMethods.GdipWindingModeOutline(path, IntPtr.Zero, 0.25F);
        }
Esempio n. 2
0
    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Rectangle    rectangle1 = new Rectangle(30, 40, 50, 200);
        Rectangle    rectangle2 = new Rectangle(30, 190, 200, 50);
        GraphicsPath gp         = new GraphicsPath();

        gp.AddRectangle(rectangle1);
        gp.AddRectangle(rectangle2);
        HandleRef handle = new HandleRef(gp, (IntPtr)gp.GetType().GetField("nativePath", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(gp));

        GdipWindingModeOutline(handle, IntPtr.Zero, 0.25F);
        e.Graphics.DrawPath(Pens.Blue, gp);
    }
        private void panelCanvas_Paint(object sender, PaintEventArgs e)
        {
            var allPointsList = new List <PointF>();
            var graphicsPath  = new GraphicsPath();
            var penIndex      = 0;
            var g             = e.Graphics;

            g.SmoothingMode        = SmoothingMode.AntiAlias;
            CanvasManager.Graphics = g;

            //DrawCheckerboard(g);
            //return;

            // Set the canvas background color
            panelCanvas.BackColor = ColorUtilities.GetColorFromHexRGBString(UserSettings.CanvasBackgroundColor);

            // Set up the coordinate mapping
            MapRectangles(g,
                          0, Controller.DataManager.MaximumX, 0, DataManager.MaximumY, // World Coordinates
                          0 + UserSettings.CanvasMarginLeft,                           // Device Coordinates
                          CanvasManager.Width - UserSettings.CanvasMarginRight,
                          0 + UserSettings.CanvasMarginTop,
                          CanvasManager.Height - UserSettings.CanvasMarginBottom,
                          false);

            // Set the Zoom factor
            CanvasManager.Zoom(_canvasZoomFactor);

            foreach (BuildingCoordinates buildingData in DataManager.InputData)
            {
                var left   = buildingData.Left;
                var height = buildingData.Height;
                var right  = buildingData.Right;
                var width  = buildingData.Width;
                var bottom = 0;

                graphicsPath.AddRectangle(new Rectangle(left, bottom, width, height));

                HandleRef handle = new HandleRef(graphicsPath,
                                                 (IntPtr)graphicsPath.
                                                 GetType().
                                                 GetField("nativePath", BindingFlags.NonPublic |
                                                          BindingFlags.Instance).
                                                 GetValue(graphicsPath));

                GdipWindingModeOutline(handle, IntPtr.Zero, 0.25F);

                if (!UserSettings.HighlightSkyline)
                {
                    // Draw the building outline rectangle
                    DrawBuildingOutline(g, _pens[penIndex], left, bottom, right, height);
                }

                penIndex = GetNextPenArrayIndex(penIndex, _pens.Length);
            }

            if (UserSettings.HighlightSkyline)
            {
                DrawSkyline(g, graphicsPath,
                            UserSettings.SkylineBorderWidth,
                            UserSettings.SkylineBorderColor,
                            UserSettings.SkylineFillFlag,
                            UserSettings.SkylineFillForegroundColor,
                            UserSettings.SkylineFillBackgroundColor);
            }

            if (UserSettings.ShowDataCoordinates)
            {
                //g.ResetTransform();

                // Set up the coordinate mapping
                //MapRectangles(g,
                //              0, DataManager.MaximumX, 0, DataManager.MaximumY, // World Coordinates
                //              0 + Settings.CanvasMarginLeft,                    // Device Coordinates
                //              CanvasManager.Width - Settings.CanvasMarginRight,
                //              0 + Settings.CanvasMarginTop,
                //              CanvasManager.Height - Settings.CanvasMarginBottom,
                //              false);

                DrawDataCoordinates(g, graphicsPath.PathData);
            }

            // Save the path data points to a file
            DataManager.WriteOutputPathDataToFile(graphicsPath.PathData);

            // Clear out all of the transforms on the graphics object
            g.ResetTransform();

            // Ensure the canvas dimensions are correct and optionally
            // display the X and/ or Y Axis.
            DrawAxis();

            // Render the grid
            DrawGrid();
        }