Ejemplo n.º 1
0
 public WpfDeviceEngine()
     : base("wpf:wpf")
 {
     unsafe
     {
         Features->flags = DeviceFeatures.DoesTrueColor;
         Features->default_margin = new pointf(0, 0);
         Features->default_pagesize = new pointf(612, 792);
         Features->default_dpi = new pointf(72, 72);
     }
 }
Ejemplo n.º 2
0
        public DeviceEngine(string type)
        {
            this._initialize = Initialize;
            this._format = Format;
            this._finalize = Finalize;

            unsafe
            {
                gvdevice_engine_t* deviceEngine = (gvdevice_engine_t*)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(gvdevice_engine_t)));
                _deviceEngine = new SafeMarshalHGlobalHandle((IntPtr)deviceEngine, true);

                *deviceEngine = new gvdevice_engine_t();
                deviceEngine->initialize = Marshal.GetFunctionPointerForDelegate(_initialize);
                deviceEngine->format = Marshal.GetFunctionPointerForDelegate(_format);
                deviceEngine->finalize = Marshal.GetFunctionPointerForDelegate(_finalize);

                gvdevice_features_t* deviceFeatures = (gvdevice_features_t*)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(gvdevice_features_t)));
                _deviceFeatures = new SafeMarshalHGlobalHandle((IntPtr)deviceFeatures, true);

                *deviceFeatures = new gvdevice_features_t();
                deviceFeatures->flags = DeviceFeatures.None;
                deviceFeatures->default_margin = new pointf(36, 36);
                deviceFeatures->default_pagesize = new pointf(612, 792);
                deviceFeatures->default_dpi = new pointf(72, 72);

                gvplugin_installed_t* installedPluginData = (gvplugin_installed_t*)Marshal.AllocHGlobal(2 * Marshal.SizeOf(typeof(gvplugin_installed_t)));
                _installedPluginData = new SafeMarshalHGlobalHandle((IntPtr)installedPluginData, true);
                _engineType = new SafeMarshalHGlobalHandle(Marshal.StringToHGlobalAnsi(type), true);

                installedPluginData->id = 0;
                installedPluginData->type = (byte*)_engineType.DangerousGetHandle();
                installedPluginData->quality = 0;
                installedPluginData->engine = deviceEngine;
                installedPluginData->features = deviceFeatures;
                installedPluginData[1] = new gvplugin_installed_t();
            }
        }
Ejemplo n.º 3
0
 protected virtual void TextParagraph(JobHandle job, pointf p, ref textpara_t text)
 {
 }
Ejemplo n.º 4
0
 protected virtual void Polyline(JobHandle job, pointf[] A, int n)
 {
 }
Ejemplo n.º 5
0
 protected virtual void Polygon(JobHandle job, pointf[] A, int n, bool filled)
 {
 }
Ejemplo n.º 6
0
 protected virtual void LibraryShape(JobHandle job, string name, pointf[] A, int n, bool filled)
 {
 }
Ejemplo n.º 7
0
 protected virtual void Ellipse(JobHandle job, pointf[] ps, bool filled)
 {
 }
Ejemplo n.º 8
0
 protected virtual void BezierCurve(JobHandle job, pointf[] A, int n, bool arrow_at_start, bool arrow_at_end, bool filled)
 {
 }
Ejemplo n.º 9
0
        protected override void BezierCurve(JobHandle job, pointf[] A, int n, bool arrow_at_start, bool arrow_at_end, bool filled)
        {
            List<PathFigure> figures = new List<PathFigure>();

            if (n % 3 == 1 && n >= 4)
            {
                PathFigure figure = new PathFigure();
                figure.StartPoint = new Point(A[0].x, A[0].y);

                for (int i = 0; i < n / 3; i++)
                {
                    Point point1 = new Point(A[3 * i + 1].x, A[3 * i + 1].y);
                    Point point2 = new Point(A[3 * i + 2].x, A[3 * i + 2].y);
                    Point point3 = new Point(A[3 * i + 3].x, A[3 * i + 3].y);
                    figure.Segments.Add(new BezierSegment(point1, point2, point3, true));
                }

                figures.Add(figure);
            }
            else
            {
                throw new NotImplementedException();
            }

            Path path;
            path = new Path()
            {
                Data = new PathGeometry(figures)
            };

            ApplyShapeStyle(path, job, filled);

            _canvas.Children.Add(path);

            //PathGeometry geometry = new PathGeometry();

            //PathFigure figure = new PathFigure();
            //figure.Segments.Add(new BezierSegment());

            //geometry.Figures.Add(new PathFigure());

            //path.Data = new PathGeometry();
            //PathGeometry geometry = (PathGeometry)path.Data;
        }
Ejemplo n.º 10
0
        protected override void TextParagraph(JobHandle job, pointf p, ref textpara_t text)
        {
            TextBlock block = new TextBlock();
            block.Inlines.Add(text.Text);
            block.FontFamily = new FontFamily(text.FontName);
            block.FontSize = text.fontsize;
            block.Margin = new Thickness(p.x - text.width / 2, p.y - text.yoffset_centerline - text.height / 2, 0, 0);
            block.Height = text.height;
            block.Width = text.width;
            block.Foreground = GetForegroundBrush(job);
            block.Background = GetBackgroundBrush(job, false);

            switch ((char)text.just)
            {
            case 'l':
                block.TextAlignment = TextAlignment.Left;
                break;

            case 'n':
                block.TextAlignment = TextAlignment.Center;
                break;

            case 'r':
                block.TextAlignment = TextAlignment.Right;
                break;
            }

            _canvas.Children.Add(block);
        }
Ejemplo n.º 11
0
        protected override void Polyline(JobHandle job, pointf[] A, int n)
        {
            Polyline polyline = new Polyline();
            for (int i = 0; i < n; i++)
                polyline.Points.Add(new Point(A[i].x, A[i].y));

            ApplyShapeStyle(polyline, job, false);

            _canvas.Children.Add(polyline);
        }
Ejemplo n.º 12
0
        protected override void Polygon(JobHandle job, pointf[] A, int n, bool filled)
        {
            Polygon polygon = new Polygon();
            for (int i = 0; i < n; i++)
                polygon.Points.Add(new Point(A[i].x, A[i].y));

            ApplyShapeStyle(polygon, job, filled);

            _canvas.Children.Add(polygon);
        }
Ejemplo n.º 13
0
 protected override void LibraryShape(JobHandle job, string name, pointf[] A, int n, bool filled)
 {
 }
Ejemplo n.º 14
0
        protected override void Ellipse(JobHandle job, pointf[] ps, bool filled)
        {
            pointf center = ps[0];
            pointf corner = ps[1];

            Ellipse ellipse = new Ellipse();
            ellipse.Width = 2 * (corner.x - center.x);
            ellipse.Height = 2 * (center.y - corner.y);
            ellipse.Margin = new Thickness(2 * center.x - corner.x, corner.y, 0, 0);

            ApplyShapeStyle(ellipse, job, filled);

            _canvas.Children.Add(ellipse);
        }