ImageList for Console Application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?anAybXNmdA==?=

    ImageList for Console Application

    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.Window s.Forms.ImageLi stStreamer)
    resources.GetOb ject("imageList 1.ImageStream") ));
    //
    It is erroring because I do not have anything called "imageList1.Ima geStream".

    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?
  • sloan

    #2
    Re: ImageList for Console Application


    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.Replac e(".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.Diagnost ics.Process.Sta rt(fileName);


    }





    public string WriteToTempFile (string toWrite)
    {

    System.IO.Strea mWriter writer = null;
    System.IO.FileS tream fs = null;
    string fileName = string.Empty;
    try
    {

    // Writes text to a temporary file and returns path
    fileName = System.IO.Path. GetTempFileName ();
    fileName = fileName.Replac e(".tmp", ".txt");
    fs = new System.IO.FileS tream(fileName,
    System.IO.FileM ode.Append, System.IO.FileA ccess.Write);
    // Opens stream and begins writing
    writer = new System.IO.Strea mWriter(fs);
    writer.BaseStre am.Seek(0, System.IO.SeekO rigin.End);
    writer.WriteLin e(toWrite);
    writer.Flush();



    }
    finally
    {
    if (null != writer)
    {
    writer.Close();
    }
    if (null != fs)
    {
    fs.Close();
    }
    }


    return fileName;

    }







    "jp2msft" <jp2msft@discus sions.microsoft .comwrote in message
    news:1F403A74-62AA-48FA-AB55-D45FF2E79802@mi crosoft.com...
    >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.Window s.Forms.ImageLi stStreamer)
    resources.GetOb ject("imageList 1.ImageStream") ));
    //
    It is erroring because I do not have anything called
    "imageList1.Ima geStream".
    >
    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?

    Comment

    Working...