示例#1
0
        private MainWindow(Builder builder)
            : base(builder.GetObject("MainWindow").Handle)
        {
            builder.Autoconnect(this);
            DeleteEvent += OnWindowDeleteEvent;

            skiaView = new SKDrawingArea();
            skiaView.PaintSurface += OnPaintSurface;
            skiaView.Show();
            Child = skiaView;
        }
示例#2
0
        public SharpApp() : base("Center")
        {
            SetDefaultSize(250, 200);
            SetPosition(WindowPosition.Center);

            DeleteEvent += delegate { Application.Quit(); };

            VBox vbox = new VBox(false, 5);
            HBox hbox = new HBox(true, 3);

            var drawingArea = new SKDrawingArea();

            drawingArea.SetSizeRequest(100, 100);
            drawingArea.PaintSurface += (sender, e) => {
                var surface       = e.Surface;
                var surfaceWidth  = e.Info.Width;
                var surfaceHeight = e.Info.Height;

                var canvas = surface.Canvas;

                // draw on the canvas

                canvas.Clear(new SkiaSharp.SKColor(255, 255, 255));
                canvas.Flush();
            };


            Alignment valign = new Alignment(0, 1, 0, 0);

            vbox.PackStart(valign, true, false, 1);
            vbox.Add(drawingArea);


            Button ok = new Button("OK");

            ok.SetSizeRequest(70, 30);
            Button close = new Button("Close");

            hbox.Add(ok);
            hbox.Add(close);

            Alignment halign = new Alignment(1, 0, 0, 0);

            halign.Add(hbox);

            vbox.PackStart(halign, false, false, 3);

            Add(vbox);

            ShowAll();
        }
示例#3
0
        public GtkDrawspace(GraphicsProvider provider, Rect2D subrect)
        {
            Provider             = provider;
            _lastPaintTime       = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            _window              = new Window("Drawspace");
            _window.DeleteEvent += OnWindowDeleteEvent;
            _window.SetDefaultSize((int)subrect.Size.X, (int)subrect.Size.Y);
            _window.Move((int)subrect.Position.X, (int)subrect.Position.Y);
            _skiaView = new SKDrawingArea();
            _skiaView.PaintSurface += OnPaintSurface;
            _skiaView.Show();
            _window.Child = _skiaView;

            TEXTALIGN[(int)IDrawspace.HORIZONTAL_ALIGNMENT.LEFT]   = SKTextAlign.Left;
            TEXTALIGN[(int)IDrawspace.HORIZONTAL_ALIGNMENT.CENTER] = SKTextAlign.Center;
            TEXTALIGN[(int)IDrawspace.HORIZONTAL_ALIGNMENT.RIGHT]  = SKTextAlign.Right;
            _skiaView.PaintSurface += OnPaintSurface;
            // init matrix stack
            _xformStack.Push(SKMatrix.MakeIdentity());
            _window.ShowAll();
        }