Exemplo n.º 1
0
    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        Graphics1 = e.Graphics;
        Surface1  = new Win32Surface(Graphics1.GetHdc());
        Context1  = new Context(Surface1);
        var p1 = new PointD(10, 10);
        var p2 = new PointD(100, 10);
        var p3 = new PointD(100, 100);
        var p4 = new PointD(10, 100);

        Context1.MoveTo(p1);
        Context1.LineTo(p2);
        Context1.LineTo(p3);
        Context1.LineTo(p4);
        Context1.LineTo(p1);
        Context1.ClosePath();
        Context1.Fill();
        Context1.MoveTo(140, 110);
        Context1.SetFontSize(32);
        Context1.SetSourceColor(new Color(0, 0, 0.8, 1));
        Context1.ShowText("Hello Cairo!");
        Graphics1.Dispose();
        Context1.Dispose();
        Surface1.Dispose();
    }
Exemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            using (Graphics1 = e.Graphics)
                using (Surface1 = new Win32Surface(Graphics1.GetHdc()))
                    using (Context1 = new Context(Surface1))
                    {
                        if (OnPaintAction != null)
                        {
                            OnPaintAction(Context1);
                        }
                    }
        }
Exemplo n.º 3
0
        private void saveAsPngToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter   = "PNG|*.png";
            dialog.FileName = lastSelected;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                using (this.Graphics1 = this.CreateGraphics())
                    using (Surface1 = new Win32Surface(Graphics1.GetHdc()))
                        using (Context1 = new Context(Surface1))
                        {
                            Surface1.WriteToPng(dialog.FileName);
                        }
            }
        }
Exemplo n.º 4
0
 public CairoContext(System.Windows.Forms.PaintEventArgs e) : base(e)
 {
     Graphics1 = e.Graphics;
     Surface1  = new Win32Surface(Graphics1.GetHdc());
     Context1  = new Context(Surface1);
 }