diff --git a/Demo/Windows/DrawPngInMemory/Form1.cs b/Demo/Windows/DrawPngInMemory/Form1.cs new file mode 100644 index 0000000..369678a --- /dev/null +++ b/Demo/Windows/DrawPngInMemory/Form1.cs @@ -0,0 +1,39 @@ +using System.Windows.Forms; +using Cairo; +using Color = Cairo.Color; +using Graphics = System.Drawing.Graphics; + +namespace DrawPngInMemory +{ + public partial class Form1 : Form + { + public Graphics Graphics1 { get; private set; } + public Context Context1 { get; set; } + public Win32Surface Surface1 { get; private set; } + byte[] pngData = System.IO.File.ReadAllBytes("1.png"); + + public Form1() + { + InitializeComponent(); + } + + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + Graphics1 = e.Graphics; + Surface1 = new Win32Surface(Graphics1.GetHdc()); + Context1 = new Context(Surface1); + + using (ImageSurface pngImageSurface = new ImageSurface(pngData)) + { + Context1.SetSource(pngImageSurface); + Context1.Paint(); + } + + Graphics1.Dispose(); + Context1.Dispose(); + Surface1.Dispose(); + } + } +} diff --git a/Demo/Windows/DrawPngInMemory/Program.cs b/Demo/Windows/DrawPngInMemory/Program.cs new file mode 100644 index 0000000..3568c84 --- /dev/null +++ b/Demo/Windows/DrawPngInMemory/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DrawPngInMemory +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/Demo/Windows/WinFormDemo/Form1.Designer.cs b/Demo/Windows/WinFormDemo/Form1.Designer.cs new file mode 100644 index 0000000..15970b8 --- /dev/null +++ b/Demo/Windows/WinFormDemo/Form1.Designer.cs @@ -0,0 +1,49 @@ +using Cairo; + +namespace WinFormDemo +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(384, 262); + this.Name = "Form1"; + this.Text = "CairoDemo cairo version: 1.14.2"; + this.ResumeLayout(false); + + } + + #endregion + } +} + diff --git a/Demo/Windows/WinFormDemo/Program.cs b/Demo/Windows/WinFormDemo/Program.cs new file mode 100644 index 0000000..c5e47d2 --- /dev/null +++ b/Demo/Windows/WinFormDemo/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace WinFormDemo +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +}