mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 18:35:31 +00:00
new example/test for Rsvg
svn path=/trunk/gtk-sharp/; revision=32795
This commit is contained in:
parent
8e8cb3ebcb
commit
87ca50791c
30
sample/rsvg/SvgFromResource.cs
Normal file
30
sample/rsvg/SvgFromResource.cs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using Gtk;
|
||||||
|
using Rsvg;
|
||||||
|
|
||||||
|
class RsvgResourceTest : Window
|
||||||
|
{
|
||||||
|
static void Main ()
|
||||||
|
{
|
||||||
|
Application.Init ();
|
||||||
|
new RsvgResourceTest ();
|
||||||
|
Application.Run ();
|
||||||
|
}
|
||||||
|
|
||||||
|
RsvgResourceTest () : base ("Rsvg Draw Test")
|
||||||
|
{
|
||||||
|
this.DeleteEvent += new DeleteEventHandler (OnWinDelete);
|
||||||
|
|
||||||
|
Image image = new Image ();
|
||||||
|
image.Pixbuf = Pixbuf.LoadFromResource ("sample.svg");
|
||||||
|
this.Add (image);
|
||||||
|
|
||||||
|
this.ShowAll ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnWinDelete (object sender, DeleteEventArgs e)
|
||||||
|
{
|
||||||
|
Application.Quit ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
37
sample/rsvg/SvgFromStream.cs
Normal file
37
sample/rsvg/SvgFromStream.cs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Gtk;
|
||||||
|
using Rsvg;
|
||||||
|
|
||||||
|
class RsvgResourceTest : Window
|
||||||
|
{
|
||||||
|
static void Main ()
|
||||||
|
{
|
||||||
|
Application.Init ();
|
||||||
|
new RsvgResourceTest ();
|
||||||
|
Application.Run ();
|
||||||
|
}
|
||||||
|
|
||||||
|
RsvgResourceTest () : base ("Rsvg Draw Test")
|
||||||
|
{
|
||||||
|
this.DeleteEvent += new DeleteEventHandler (OnWinDelete);
|
||||||
|
|
||||||
|
Image image = new Image ();
|
||||||
|
|
||||||
|
// contrived way to get a stream
|
||||||
|
System.IO.Stream s = System.Reflection.Assembly.GetCallingAssembly ().GetManifestResourceStream ("sample.svg");
|
||||||
|
if (s == null)
|
||||||
|
throw new ArgumentException ("resource must be a valid resource name of 'assembly'.");
|
||||||
|
|
||||||
|
image.Pixbuf = Pixbuf.LoadFromStream (s);
|
||||||
|
this.Add (image);
|
||||||
|
|
||||||
|
this.ShowAll ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnWinDelete (object sender, DeleteEventArgs e)
|
||||||
|
{
|
||||||
|
Application.Quit ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ using Gtk;
|
||||||
{
|
{
|
||||||
this.DeleteEvent += new Gtk.DeleteEventHandler(delete_event);
|
this.DeleteEvent += new Gtk.DeleteEventHandler(delete_event);
|
||||||
string svg_file_name = "sample.svg";
|
string svg_file_name = "sample.svg";
|
||||||
Gdk.Pixbuf pixbuf = Rsvg.Tool.PixbufFromFile (svg_file_name);
|
Gdk.Pixbuf pixbuf = Rsvg.Pixbuf.FromFile (svg_file_name);
|
||||||
|
|
||||||
Gtk.Image image = new Gtk.Image();
|
Gtk.Image image = new Gtk.Image();
|
||||||
image.Pixbuf = pixbuf;
|
image.Pixbuf = pixbuf;
|
||||||
|
|
Loading…
Reference in a new issue