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

View File

@ -97,13 +97,13 @@ namespace GtkDemo
textView.AddChildAtAnchor (scale, scaleAnchor);
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);
image.ShowAll ();
Entry entry = new Entry ();
textView.AddChildAtAnchor (entry, entryAnchor);
image.ShowAll ();
entry.ShowAll ();
}
private void CreateTags (TextBuffer buffer)

View File

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