Esempio n. 1
0
    void PrintWithBounds(Alt.Sketch.Graphics graphics, QFont font, string text, Alt.Sketch.Rect bounds, QFontAlignment alignment, ref double yOffset)
    {
        double maxWidth = bounds.Width;

        double height = font.Measure(text, maxWidth, alignment).Height;

        bounds.Height = height;
        graphics.DrawRectangle(m_LinesPen, bounds - new Point(1, 0) + new Size(0, 1));

        font.Print(text, maxWidth, alignment, new Alt.Sketch.Vector2(bounds.X, bounds.Y));

        yOffset += height;
    }
Esempio n. 2
0
        protected override void SetClipRectangle(Alt.Sketch.Rect rectangle)
        {
            rectangle = new Alt.Sketch.Rect(
                (int)(rectangle.Left + 0.5),
                (int)(rectangle.Top + 0.5),
                (int)(rectangle.Width + 0.5),
                (int)(rectangle.Height + 0.5));

            if (m_LastClipRectangle != rectangle)
            {
                m_LastClipRectangle = rectangle;
#if TRY_CLIPPINGRECT
                UpdateMatrices();
#endif
            }
        }
        protected override void OnPaint(Alt.GUI.PaintEventArgs e)
        {
            base.OnPaint(e);


            Alt.Sketch.Graphics graphics = e.Graphics;


            Matrix matrix = graphics.Transform;

            {
                //  correct offset
                Alt.Sketch.Rect clientRectangle = ClientRectangle;
                Alt.Sketch.Rect rect            = clientRectangle;
                double          targetX         = (m_TargetX - (clientRectangle.Width / 2)) * clientRectangle.Width / rect.Width + clientRectangle.Width / 2;
                double          targetY         = (m_TargetY - (clientRectangle.Height / 2)) * clientRectangle.Height / rect.Height + clientRectangle.Height / 2;
                graphics.TranslateTransform(targetX, targetY);

                graphics.RotateTransform(angle);

                int radialStep = 30;
                int nSteps     = 5;
                int lineDXY    = radialStep * (nSteps + 1);

                graphics.FillCircle(m_TargetBrush, 0, 0, radialStep * nSteps);

                graphics.SmoothingMode = SmoothingMode.AntiAlias;

                graphics.DrawLine(m_TargetPen, 0, -lineDXY, 0, lineDXY);
                graphics.DrawLine(m_TargetPen, -lineDXY, 0, lineDXY, 0);

                for (int i = 1; i <= nSteps; i++)
                {
                    graphics.DrawCircle(m_TargetPen, 0, 0, radialStep * i);
                }
            }
            graphics.Transform = matrix;
        }
Esempio n. 4
0
            public void LoadSVG(string fileName)
            {
                try
                {
                    m_svgDoc = SvgDocument.Open(fileName);
                    if (m_svgDoc == null)
                    {
                        return;
                    }

                    m_SVGPathBounds = new Alt.Sketch.Rect(m_svgDoc.Bounds.X, m_svgDoc.Bounds.Y, m_svgDoc.Bounds.Width, m_svgDoc.Bounds.Height);

                    Size clientSize = ClientSize;
                    m_Scale = System.Math.Min(clientSize.Width / m_SVGPathBounds.Width, clientSize.Height / m_SVGPathBounds.Height);

                    Invalidate();
                }
                catch (Exception ex)                //SvgException)
                {
                    Console.WriteLine(ex.ToString());

                    return;
                }
            }
Esempio n. 5
0
    protected void Paint_onPaint(Alt.GUI.PaintEventArgs e)
    {
#if UNITY_5 && USE_ExtBrush
        if (e.Graphics is SoftwareGraphics)
        {
            return;
        }

        Alt.Sketch.Color colorMultiplier;
#endif

        int opacity = 128;

        if (m_MaterialBrush1 == null)
        {
#if UNITY_5 && USE_ExtBrush
            Bitmap image = Bitmap.FromFile("AltData/About.gif");

            ExtBrush brush;
            brush = new ExtBrush(); brush.MaterialName = "Material1"; brush.SetExtParameter("Image", image); m_MaterialBrush1 = brush;
            brush = new ExtBrush(); brush.MaterialName = "Material2"; brush.SetExtParameter("Image", image); m_MaterialBrush2 = brush;
            brush = new ExtBrush(); brush.MaterialName = "Material3"; brush.SetExtParameter("Image", image); m_MaterialBrush3 = brush;
            brush = new ExtBrush(); brush.MaterialName = "Material4"; brush.SetExtParameter("Image", image); m_MaterialBrush4 = brush;
#else
            SolidColorBrush brush;
            brush = new SolidColorBrush(Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.Red)); m_MaterialBrush1 = brush;
            brush = new SolidColorBrush(Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.Green)); m_MaterialBrush2 = brush;
            brush = new SolidColorBrush(Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.DodgerBlue)); m_MaterialBrush3 = brush;
            brush = new SolidColorBrush(Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.Yellow)); m_MaterialBrush4 = brush;
#endif
        }


        Brush currentBrush;

        switch (m_CurrentBrush)
        {
        case 0:
            currentBrush = m_MaterialBrush1;
#if UNITY_5 && USE_ExtBrush
            colorMultiplier = Alt.Sketch.Color.LightCoral;
#endif
            break;

        case 1:
            currentBrush = m_MaterialBrush2;
#if UNITY_5 && USE_ExtBrush
            colorMultiplier = Alt.Sketch.Color.Green;
#endif
            break;

        case 2:
            currentBrush = m_MaterialBrush3;
#if UNITY_5 && USE_ExtBrush
            colorMultiplier = Alt.Sketch.Color.Red;
#endif
            break;

        case 3:
            currentBrush = m_MaterialBrush4;
#if UNITY_5 && USE_ExtBrush
            colorMultiplier = Alt.Sketch.Color.Cyan;
#endif
            break;

        default:
            return;
        }

        Alt.Sketch.Graphics graphics = e.Graphics;
        graphics.SmoothingMode = SmoothingMode.None;

        Alt.Sketch.Rect rect = e.ClipRectangle;
        rect.Deflate(50 + offset, 50 + offset);

        graphics.FillRoundedRectangle(currentBrush, rect, 20
#if UNITY_5 && USE_ExtBrush
                                      , colorMultiplier
#else
                                      , UseHardwareRender ? Alt.Sketch.Color.FromArgb(opacity, Alt.Sketch.Color.White) : Alt.Sketch.Color.White
#endif
                                      );

        graphics.SmoothingMode = SmoothingMode.AntiAlias;
        graphics.DrawRoundedRectangle(m_ContourPen, rect, 20);
    }