コード例 #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);


            //
            m_Client = new DoubleBufferedControl(this);
            m_Client.ClientBackColor = Color.Empty;
            m_Client.Dock            = Pos.Fill;
            m_Client.Paint          += new GUI.PaintEventHandler(Client_Paint);


            //
            m_AltNETTypeFontManager       = new SimpleFontCacheManager();
            m_AltNETTypeFontManager.FlipY = true;

            m_mtx          = Matrix4.Identity;
            m_FlattenGlyph = new FlattenCurveGeometry();
            //m_FlattenGlyph.ApproximationScale = 4.0;

            m_TransformedFlattenGlyph         = new GeometryMatrix4Transformer(m_FlattenGlyph, m_mtx);
            m_WeightedTransformedFlattenGlyph = new GeometryAuxWeight(m_TransformedFlattenGlyph);


            //  update labels
            control_ValueChanged(null);
        }
コード例 #2
0
ファイル: GeometryAuxWeight.cs プロジェクト: CrazyLiu00/GMap
        public GeometryAuxWeight(Geometry geometry)
        {
            m_mtx_zoom_in_y   = Matrix4.CreateScaling(1, 100);
            m_mtx_zoom_out_y  = Matrix4.CreateScaling(1, 1.0 / 100.0);
            m_trans_zoom_in_y = GeometryMatrix4Transformer.CreateOptimizedTransformer(geometry, m_mtx_zoom_in_y);
            m_contour         = new GeometryContour(m_trans_zoom_in_y);
            m_trans_zoom_out  = GeometryMatrix4Transformer.CreateOptimizedTransformer(m_contour, m_mtx_zoom_out_y);

            m_contour.AutoDetectOrientation = false;

            Geometry = m_trans_zoom_out;
        }
コード例 #3
0
        public SVGPath()
        {
            m_storage      = new GraphicsPath();
            m_attr_storage = new List <SVGPathAttributes>();
            m_attr_stack   = new List <SVGPathAttributes>();
            m_transform    = Matrix4.Identity;

            m_curved = new FlattenCurveGeometry(m_storage);

            m_curved_stroked       = new GeometryStroke(m_curved);
            m_curved_stroked_trans = new GeometryMatrix4Transformer(m_curved_stroked, m_transform);

            m_curved_trans         = new GeometryMatrix4Transformer(m_curved, m_transform);
            m_curved_trans_contour = new GeometryContour(m_curved_trans);

            m_curved_trans_contour.AutoDetectOrientation = false;
        }
コード例 #4
0
ファイル: Example_Contour.cs プロジェクト: CrazyLiu00/GMap
        protected override void OnPaint(GUI.PaintEventArgs e)
        {
            base.OnPaint(e);


            Graphics graphics = e.Graphics;

            graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            graphics.SmoothingMode     = SmoothingMode.AntiAlias;


            Geometry outlinePath = GeometryMatrix4Transformer.
                                   CreateOptimizedTransformer(Common.GraphicsPath_AltSketch,
                                                              Matrix4.CreateScaling(0.9 * ClientWidth / Common.GraphicsPath_AltSketch_Bounds.Width));
            Rect  outlinePathBounds = outlinePath.Bounds;
            Point textOffset        = ((ClientSize - outlinePathBounds.Size) / 2).ToPoint();

            graphics.TranslateTransform(textOffset.X, textOffset.Y - outlinePathBounds.Top);


            GeometryVertexCommandAndFlags flag = GeometryVertexCommandAndFlags.None;

            if (rbCloseCW.IsChecked)
            {
                flag = GeometryVertexCommandAndFlags.FlagCW;
            }
            else if (rbCloseCCW.IsChecked)
            {
                flag = GeometryVertexCommandAndFlags.FlagCCW;
            }

            SpecialContourGeometry specialContourGeometry = new SpecialContourGeometry(outlinePath, flag);
            FlattenCurveGeometry   curve   = new FlattenCurveGeometry(specialContourGeometry);
            GeometryContour        contour = new GeometryContour(curve);

            contour.Width = m_WidthSlider.Value;
            contour.AutoDetectOrientation = m_AutoDetectCheckBox.IsChecked;


            graphics.FillGeometry(m_FillBrush, contour);
            graphics.DrawGeometry(m_ContourPen, contour);
        }
コード例 #5
0
        void panel2_Paint(object sender, GUI.PaintEventArgs e)
        {
            Graphics graphics           = e.Graphics;
            bool     isSoftwareGraphics = graphics is SoftwareGraphics;

            //if (isSoftwareGraphics)
            {
                graphics.SmoothingMode = SmoothingMode.AntiAlias;
            }


            // Two simple paths
            if (rbGeometry5.IsChecked)
            {
                GraphicsPath ps1_path = new GraphicsPath();

                double x = m_X - m_DrawingPanel.ClientRectangle.Center.X / 2 + 100;
                double y = m_Y - m_DrawingPanel.ClientRectangle.Center.Y / 2 + 100;
                ps1_path.MoveTo(x + 140, y + 145);
                ps1_path.LineTo(x + 225, y + 44);
                ps1_path.LineTo(x + 296, y + 219);
                ps1_path.ClosePolygon();

                ps1_path.LineTo(x + 226, y + 289);
                ps1_path.LineTo(x + 82, y + 292);

                ps1_path.MoveTo(x + 220, y + 222);
                ps1_path.LineTo(x + 363, y + 249);
                ps1_path.LineTo(x + 265, y + 331);

                ps1_path.MoveTo(x + 242, y + 243);
                ps1_path.LineTo(x + 268, y + 309);
                ps1_path.LineTo(x + 325, y + 261);

                ps1_path.MoveTo(x + 259, y + 259);
                ps1_path.LineTo(x + 273, y + 288);
                ps1_path.LineTo(x + 298, y + 266);

                Rect ps1Bounds          = ps1_path.Bounds;
                GeometryTransformer ps1 = GeometryMatrix4Transformer.CreateOptimizedTransformer(ps1_path, Matrix4.CreateTranslation(
                                                                                                    m_X - ps1Bounds.Center.X,
                                                                                                    m_Y - ps1Bounds.Center.Y));


                GraphicsPath ps2_path = new GraphicsPath();
                ps2_path.MoveTo(100 + 32, 100 + 77);
                ps2_path.LineTo(100 + 473, 100 + 263);
                ps2_path.LineTo(100 + 351, 100 + 290);
                ps2_path.LineTo(100 + 354, 100 + 374);
                Rect ps2Bounds          = ps2_path.Bounds;
                GeometryTransformer ps2 = GeometryMatrix4Transformer.CreateOptimizedTransformer(ps2_path, Matrix4.CreateTranslation(
                                                                                                    (m_DrawingPanel.Width - ps2Bounds.Width) / 2 - ps2Bounds.Left,
                                                                                                    (m_DrawingPanel.Height - ps2Bounds.Height) / 2 - ps2Bounds.Top));


                graphics.FillGeometry(m_GeometryBColor, ps2);
                graphics.FillGeometry(m_GeometryAColor, ps1);

                CombinedGeometry clp = new CombinedGeometry(ps1, ps2, CombinedGeometry.CombineMode.Or, CombinedGeometry.FillType.NonZero, CombinedGeometry.FillType.NonZero);

                PerformRendering(graphics, clp);
            }
            // Closed stroke
            else if (rbGeometry4.IsChecked)
            {
                GraphicsPath ps1_path = new GraphicsPath();

                double x = m_X - m_DrawingPanel.ClientRectangle.Center.X / 2 + 100;
                double y = m_Y - m_DrawingPanel.ClientRectangle.Center.Y / 2 + 100;
                ps1_path.MoveTo(x + 140, y + 145);
                ps1_path.LineTo(x + 225, y + 44);
                ps1_path.LineTo(x + 296, y + 219);
                ps1_path.ClosePolygon();

                ps1_path.LineTo(x + 226, y + 289);
                ps1_path.LineTo(x + 82, y + 292);

                ps1_path.MoveTo(x + 220 - 50, y + 222);
                ps1_path.LineTo(x + 265 - 50, y + 331);
                ps1_path.LineTo(x + 363 - 50, y + 249);
                ps1_path.ClosePolygon(GeometryVertexCommandAndFlags.FlagCCW);

                Rect ps1Bounds          = ps1_path.Bounds;
                GeometryTransformer ps1 = GeometryMatrix4Transformer.CreateOptimizedTransformer(ps1_path, Matrix4.CreateTranslation(
                                                                                                    m_X - ps1Bounds.Center.X,
                                                                                                    m_Y - ps1Bounds.Center.Y));


                GraphicsPath ps2_path = new GraphicsPath();
                ps2_path.MoveTo(100 + 32, 100 + 77);
                ps2_path.LineTo(100 + 473, 100 + 263);
                ps2_path.LineTo(100 + 351, 100 + 290);
                ps2_path.LineTo(100 + 354, 100 + 374);
                ps2_path.ClosePolygon();
                Rect ps2Bounds          = ps2_path.Bounds;
                GeometryTransformer ps2 = GeometryMatrix4Transformer.CreateOptimizedTransformer(ps2_path, Matrix4.CreateTranslation(
                                                                                                    (m_DrawingPanel.Width - ps2Bounds.Width) / 2 - ps2Bounds.Left,
                                                                                                    (m_DrawingPanel.Height - ps2Bounds.Height) / 2 - ps2Bounds.Top));

                GeometryStroke stroke = new GeometryStroke(ps2, 10);


                graphics.FillGeometry(m_GeometryBColor, stroke);
                graphics.FillGeometry(m_GeometryAColor, ps1);

                CombinedGeometry clp = new CombinedGeometry(ps1, stroke, CombinedGeometry.CombineMode.Or, CombinedGeometry.FillType.NonZero, CombinedGeometry.FillType.NonZero);

                PerformRendering(graphics, clp);
            }
            // Great Britain and Arrows
            else if (rbGeometry3.IsChecked)
            {
                Geometry poly       = GreatBritain;
                Rect     polyBounds = poly.Bounds;
                double   scale      = 3;
                Matrix4  mtx        = Matrix4.CreateTranslation(-polyBounds.Center.X, -polyBounds.Center.Y);
                mtx *= Matrix4.CreateScaling(scale, scale);
                mtx *= Matrix4.CreateTranslation(m_DrawingPanel.Width / 2, m_DrawingPanel.Height / 2);
                GeometryTransformer trans_gb_poly = GeometryMatrix4Transformer.CreateOptimizedTransformer(poly, mtx);

                Geometry arrows       = Arrows;
                Rect     arrowsBounds = arrows.Bounds;
                mtx  = Matrix4.CreateTranslation(-arrowsBounds.Center.X, -arrowsBounds.Center.Y);
                mtx *= Matrix4.CreateScaling(scale, scale);
                mtx *= Matrix4.CreateTranslation(m_X, m_Y);
                GeometryTransformer trans_arrows = GeometryMatrix4Transformer.CreateOptimizedTransformer(arrows, mtx);

                CombinedGeometry clp = new CombinedGeometry(trans_gb_poly, trans_arrows,
                                                            CombinedGeometry.CombineMode.Or,
                                                            CombinedGeometry.FillType.NonZero,
                                                            CombinedGeometry.FillType.NonZero);

                graphics.FillGeometry(m_GeometryBColor, trans_gb_poly);
                graphics.DrawGeometry(isSoftwareGraphics ? m_GreatBritainContourPen_SWR : m_GreatBritainContourPen_HWR, trans_gb_poly);
                graphics.FillGeometry(m_GeometryAColor, trans_arrows);

                PerformRendering(graphics, clp);
            }
            // Great Britain and a Spiral
            else if (rbGeometry2.IsChecked)
            {
                Geometry poly       = GreatBritain;
                Rect     polyBounds = poly.Bounds;
                double   scale      = 3;
                Matrix4  mtx        = Matrix4.CreateTranslation(-polyBounds.Center.X, -polyBounds.Center.Y);
                mtx *= Matrix4.CreateScaling(scale, scale);
                mtx *= Matrix4.CreateTranslation(m_DrawingPanel.Width / 2, m_DrawingPanel.Height / 2);
                GeometryTransformer trans_gb_poly = GeometryMatrix4Transformer.CreateOptimizedTransformer(poly, mtx);

                Geometry       sp     = GeometryMatrix4Transformer.CreateOptimizedTransformer(Spiral, Matrix4.CreateTranslation(m_X, m_Y));
                GeometryStroke stroke = new GeometryStroke(sp, 15);

                CombinedGeometry clp = new CombinedGeometry(trans_gb_poly, stroke,
                                                            CombinedGeometry.CombineMode.Or,
                                                            CombinedGeometry.FillType.NonZero,
                                                            CombinedGeometry.FillType.NonZero);

                graphics.FillGeometry(m_GeometryBColor, trans_gb_poly);
                graphics.DrawGeometry(isSoftwareGraphics ? m_GreatBritainContourPen_SWR : m_GreatBritainContourPen_HWR, trans_gb_poly);
                graphics.DrawGeometry(m_SpiralPen, sp);

                PerformRendering(graphics, clp);
            }
            // Spiral and text
            else if (rbGeometry1.IsChecked)
            {
                Geometry            text            = Text;
                Rect                textBounds      = text.Bounds;
                GeometryTransformer transformedText = GeometryMatrix4Transformer.CreateOptimizedTransformer(text,
                                                                                                            Matrix4.CreateTranslation(
                                                                                                                (m_DrawingPanel.Width - textBounds.Width) / 2 - textBounds.Left,
                                                                                                                (m_DrawingPanel.Height - textBounds.Height) / 2 - textBounds.Top));

                Geometry       sp     = GeometryMatrix4Transformer.CreateOptimizedTransformer(Spiral, Matrix4.CreateTranslation(m_X, m_Y));
                GeometryStroke stroke = new GeometryStroke(sp, 15);

                CombinedGeometry clp = new CombinedGeometry(stroke, transformedText,
                                                            CombinedGeometry.CombineMode.Or,
                                                            CombinedGeometry.FillType.NonZero,
                                                            CombinedGeometry.FillType.NonZero);

                graphics.FillGeometry(m_GeometryBColor, transformedText);
                graphics.DrawGeometry(m_SpiralPen, sp);

                PerformRendering(graphics, clp);
            }
        }