Re: ImageList for Console Application
- From: "sloan" <sloan@xxxxxxxxx>
- Date: Tue, 18 Mar 2008 17:15:13 -0400
I guess one off the wall idea is to write out the the TEMP folder. And pop
the default application.
I don't know if this will work with a stream from the resource..but here is
my crappy string/file version.
It should convey the idea.
If you swap out to an image file extension
fileName = fileName.Replace(".tmp", ".jpg");
and work out the details of the stream writing..maybe its a poor man's fix
for showing images with a console application.
public void Test1()
string fileName = WriteToTempFile("Hi There");
System.Diagnostics.Process.Start(fileName);
}
public string WriteToTempFile(string toWrite)
{
System.IO.StreamWriter writer = null;
System.IO.FileStream fs = null;
string fileName = string.Empty;
try
{
// Writes text to a temporary file and returns path
fileName = System.IO.Path.GetTempFileName();
fileName = fileName.Replace(".tmp", ".txt");
fs = new System.IO.FileStream(fileName,
System.IO.FileMode.Append, System.IO.FileAccess.Write);
// Opens stream and begins writing
writer = new System.IO.StreamWriter(fs);
writer.BaseStream.Seek(0, System.IO.SeekOrigin.End);
writer.WriteLine(toWrite);
writer.Flush();
}
finally
{
if (null != writer)
{
writer.Close();
}
if (null != fs)
{
fs.Close();
}
}
return fileName;
}
"jp2msft" <jp2msft@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1F403A74-62AA-48FA-AB55-D45FF2E79802@xxxxxxxxxxxxxxxx
I am experimenting with a concept the engineers want.
I want to create an app that runs in the console. When an event happens, I
want to display an image.
Can I do this without having a form?
Right now, my app compiles, but crashes with an unhandled exception at
this
part:
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)
resources.GetObject("imageList1.ImageStream")));
//
It is erroring because I do not have anything called
"imageList1.ImageStream".
How would I define something like this?
I included a Resources.resx file, and loaded several images into it. I
just
don't know how to access them.
Can anyone help?
.
- Prev by Date: Re: ImageList for Console Application
- Next by Date: Re: How to debug component written in VS2003 in a VS2005 applicati
- Previous by thread: Re: ImageList for Console Application
- Next by thread: RE: configuration setting
- Index(es):
Relevant Pages
|
Loading