store the .cs files as resources also

svn path=/trunk/gtk-sharp/; revision=32944
This commit is contained in:
John Luke 2004-08-27 19:43:41 +00:00
parent 780218b349
commit 8ba7c8305b
3 changed files with 26 additions and 15 deletions

View file

@ -8,6 +8,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections; using System.Collections;
using System.Reflection;
using Gdk; using Gdk;
using Gtk; using Gtk;
@ -57,25 +58,34 @@ namespace GtkDemo
private void LoadFile (string filename) private void LoadFile (string filename)
{ {
if (File.Exists (filename)) Stream file = Assembly.GetExecutingAssembly ().GetManifestResourceStream (filename);
if (file != null)
{ {
Stream file = File.OpenRead (filename); LoadStream (file, filename);
StreamReader sr = new StreamReader (file); }
string s = sr.ReadToEnd (); else if (File.Exists (filename))
sr.Close (); {
file.Close (); file = File.OpenRead (filename);
LoadStream (file, filename);
infoBuffer.Text = filename;
sourceBuffer.Text = s;
Fontify ();
} }
else else
{ {
infoBuffer.Text = String.Format ("{0} was not found.", filename); infoBuffer.Text = String.Format ("{0} was not found.", filename);
sourceBuffer.Text = String.Empty; sourceBuffer.Text = String.Empty;
Fontify ();
} }
Fontify ();
}
private void LoadStream (Stream file, string filename)
{
StreamReader sr = new StreamReader (file);
string s = sr.ReadToEnd ();
sr.Close ();
file.Close ();
infoBuffer.Text = filename;
sourceBuffer.Text = s;
} }
private void Fontify () private void Fontify ()

View file

@ -97,13 +97,13 @@ namespace GtkDemo
textView.AddChildAtAnchor (scale, scaleAnchor); textView.AddChildAtAnchor (scale, scaleAnchor);
scale.ShowAll (); scale.ShowAll ();
Gtk.Image image = new Gtk.Image ("images/floppybuddy.gif"); Gtk.Image image = new Gtk.Image (Gdk.Pixbuf.LoadFromResource ("floppybuddy.gif"));
textView.AddChildAtAnchor (image, animationAnchor); textView.AddChildAtAnchor (image, animationAnchor);
image.ShowAll (); image.ShowAll ();
Entry entry = new Entry (); Entry entry = new Entry ();
textView.AddChildAtAnchor (entry, entryAnchor); textView.AddChildAtAnchor (entry, entryAnchor);
image.ShowAll (); entry.ShowAll ();
} }
private void CreateTags (TextBuffer buffer) private void CreateTags (TextBuffer buffer)

View file

@ -41,7 +41,8 @@ images = \
/resource:$(srcdir)/images/floppybuddy.gif,floppybuddy.gif /resource:$(srcdir)/images/floppybuddy.gif,floppybuddy.gif
build_sources = $(addprefix $(srcdir)/, $(sources)) build_sources = $(addprefix $(srcdir)/, $(sources))
resources = $(addprefix /resource:, $(sources))
GtkDemo.exe: $(build_sources) $(assemblies) GtkDemo.exe: $(build_sources) $(assemblies)
$(CSC) /debug /out:GtkDemo.exe $(build_sources) $(references) $(images) $(CSC) /debug /out:GtkDemo.exe $(build_sources) $(references) $(images) $(resources)