« August 2003 | Main | October 2003 »

September 22, 2003

Buffered Console.Out

using (StreamWriter bufferOutput = new StreamWriter(Console.OpenStandardOutput(1024))) {
    Console.SetOut(bufferOutput);
   
// ouput stuff.
} // Remaining buffered Console output flushed. What happens to Console.Out? Still valid?

September 17, 2003

ToolBar button image tricks

Changing button images for mouse over highlighting with a .NET ToolBar is a bit tricky.

This works with a little flicker, where %3==0 are normal images, & %3==2 are highlight images.

         private void toolBar_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {

              foreach (ToolBarButton b in toolBar.Buttons) {

                  if (b.Style == ToolBarButtonStyle.Separator || !b.Enabled) continue;

                  if (b.Rectangle.Contains(e.X, e.Y))

                       b.ImageIndex = (b.ImageIndex / 3) * 3 + 2;

                  else

                       b.ImageIndex = (b.ImageIndex / 3) * 3;

              }

         }

Embedded Resources, ImageLists

Discovered that images added to a project can have their build property set to “Embedded Resource”.

You can then get at them programmatically by:

Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("SharksEye.VisionVest.Resources.image_medium.ico"));

 

And then I learned that images added to an ImageList using the Visual Studio IDE are converted to embeded resources.