Nicholas Pike

Like nailing jelly to a wall…

Tip of the day: Pack before you move

without comments

uhaulSo yesterday helped Jenn clean out her apartment into a 17′ U-Haul. I have never SEEN so much stuff in my life.

Lets list it.

  • 2 Couches
  • 1 Recliner
  • 2 end tables
  • 1 coffee table
  • 1 folding table (computer sized)
  • 1 large folding table
  • 1 bed frame
  • 2 matresses
  • two mirrors
  • 4 wooden chairs
  • a computer desk
  • a mini fridge
  • several bags of clothing
  • several bags and boxes of random stuff

This is all for one person! Holly smokes!

Thanks to Billy for helping me move her stuff.

A[another] little side project

So OS X has the cool ability to rotate your desktop background at set intervals, from a folder that you point it at containing a bunch of images. Windows has never had this, and still doesn’t have it in Vista.

I through together a quick little application yesterday that does just that… its a little rough around the edges right now obviously, so I wont post it for download yet.

But I will post some code snippets for anyone interested in doing some File I/O or background changing using the Win32API .

Pick a random file from a directory

Random rnd = new Random();
string[] dirs = Directory.GetFiles(”npike/wallpapers” , “*.jpg”);
string tmpFilename = fileName;
if (dirs.Length > 1) {
while (tmpFilename == fileName) {
// make sure we dont pick the same wallpaper in a row
picIndex = (rnd.Next(dirs.Length)) % dirs.Length;
tmpFilename = dirs[picIndex];
}
} else {

tmpFilename = dirs[0];

}

Changing the wallpaper with the Win32 API

// for simplicity and conveniences, create an internal class

public class WinAPI
{
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SystemParametersInfo (int uAction , int uParam , string lpvParam , int fuWinIni) ;
public const int SPI_SETDESKWALLPAPER = 20;
public const int SPIF_SENDCHANGE = 0×2;

}

// Win32 API seems to like only bitmaps

// so if your image isnt a bitmap, youll have to convert it first!

if (Path.GetExtension(fileName).ToLower() != “.bmp”)
{
Bitmap theImage = new Bitmap(dirs[picIndex]);
fileName = Path.Combine(mySetting.m_settingsPath ,  “new.bmp”);
theImage.Save (fileName, System.Drawing.Imaging.ImageFormat.Bmp);
theImage .Dispose();
}

int nResult =  WinAPI.SystemParametersInfo(SPI_SETDESKWALLPAPER,1,fileName,SPIF_SENDCHANGE);

That’s it for now folks, when I get some time (rather, IF I get some time) I will refactor and purdy up my code and post that along with the application.

In the mean time, I have a busy weekend of helping folks move, sleeping, and playing Bioshock.

Written by npike

August 23rd, 2007 at 12:25 pm

Posted in Summer

Leave a Reply