Пример #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
        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;
        }
Пример #3
0
        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);
        }
Пример #4
0
        Tuple <Geometry, double> CreateCurveTransformedTextGeometry(string text)
        {
            double baseOffset;

            Font font = CurveTransformedText_Font;

            GraphicsPath textPath = new GraphicsPath();

            textPath.AddString(text, font.FontFamily, FontStyle.Regular, font.Size * 96 / 72, Point.Zero, StringFormat.GenericTypographic);

            if (TextUpperBaseLine)
            {
                baseOffset = 0;
                textPath.Transform(Matrix4.CreateTranslation(0, -FontAscentInPixels - 3));
            }
            else
            {
                baseOffset = -textPath.Bounds.Y + 2;
                textPath.Transform(Matrix4.CreateTranslation(0, baseOffset));
            }

            FlattenCurveGeometry curvedTextPath = new FlattenCurveGeometry(textPath);

            if (TextUpperBaseLine)
            {
                curvedTextPath.ApproximationScale = 2.0;
            }
            else
            {
                curvedTextPath.ApproximationScale = 5.0;
            }

            GeometrySegmentator segmentedCurvedTextPath = new GeometrySegmentator(curvedTextPath);

            //segmentedCurvedTextPath.ApproximationScale = 3.0;

            return(new Tuple <Geometry, double>(segmentedCurvedTextPath, baseOffset));
        }
Пример #5
0
        protected override void OnPaint(GUI.PaintEventArgs e)
        {
            base.OnPaint(e);


            Graphics graphics = e.Graphics;

            graphics.SmoothingMode = SmoothingMode.AntiAlias;


            PolarTransform polarTransform = new PolarTransform();

            polarTransform.FullCircle = -600;
            polarTransform.BaseScale  = -1;
            polarTransform.SetBaseOffset(0, m_BaseYSlider.Value);
            polarTransform.SetTranslation(ClientWidth / 2.0, ClientHeight / 2.0 - 30.0);
            polarTransform.Spiral = m_SpiralSlider.Value;


            //  Draw Background
            RectangleGeometry borderGeometry = new RectangleGeometry(0, 0, m_TextBox.Width, m_TextBox.Height);
            //  Just for little optimization
            GeometrySegmentator borderGeometrySegmentator = new GeometrySegmentator(borderGeometry);
            GeometryTransformer borderGeometrySegmentatorPolarTransformer = new GeometryTransformer(borderGeometrySegmentator, polarTransform);

            graphics.FillGeometry(Color.WhiteSmoke, borderGeometrySegmentatorPolarTransformer);


            //  Selection
            if (m_TextBox.HasSelectionAndVisible)
            {
                RectangleGeometry selectionGeometry = new RectangleGeometry(m_TextBox.SelectionBounds
                                                                            //  Just to prevent some artefacts
                                                                            - new PointI(0, 1) + new SizeI(0, 2));

                FillGeometry(graphics, polarTransform, m_TextBox.SelectionColor, selectionGeometry);
            }


            //  Caret
            if (m_TextBox.IsCaretVisible)
            {
                RectangleGeometry caretGeometry = new RectangleGeometry(m_TextBox.CaretBounds);

                FillGeometry(graphics, polarTransform, Color.Black, caretGeometry);
            }


            //  Draw Border
            graphics.DrawGeometry(Color.DodgerBlue, borderGeometrySegmentatorPolarTransformer, 2);


            //  Text
            Font         font         = m_TextBox.Font;
            GraphicsPath textGeometry = new GraphicsPath();

            textGeometry.AddString(
                m_TextBox.Text,
                font.FontFamily, font.Style, font.Size * 96.0 / 72.0, new Point(4, 1), StringFormat.GenericTypographic);

            FlattenCurveGeometry textFlattenGeometry = new FlattenCurveGeometry(textGeometry);
            //  Need for clip text
            Geometry clippedTextFlattenGeometry = new FlattenCurveGeometry(
                new CombinedGeometry(textFlattenGeometry, new RectangleGeometry(1, 1, m_TextBox.Width - 2, m_TextBox.Height - 2), CombinedGeometry.CombineMode.And));

            FillGeometry(graphics, polarTransform, m_TextBox.TextColor, clippedTextFlattenGeometry);
        }