UpTime.Net

PerformanceCounter pc = new PerformanceCounter(“System”,
    “System Up Time”);

 

//Normally starts with zero. do Next Value always.

pc.NextValue();

TimeSpan ts = TimeSpan.FromSeconds(pc.NextValue());

MessageBox.Show(Environment.MachineName +

    ” has been up for \n\n” +

    (ts.Days < 1 ? “” : ts.Days + ” days, “) +

    (ts.Hours < 1 ? “” : ts.Hours + ” hours, “) +

    (ts.Minutes < 1 ? “” : ts.Minutes + ” minutes “) +

    ” and “ + ts.Seconds + ” seconds.”);

Nice, neat and simple.

Get a compiled executable here

Popularity: 31% [?]

Posted in .Net Framework, C#, Downloadable
 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 (No Ratings Yet)
Loading ... Loading ...
| No Comments »

How to get Website Thumbnail in C#

[Edit: I’ve posted it on CodeProject and there are some greatl people commenting on it that did the investigation on ho to wrap it in a STA Thread and make it a part of your ASP.Net solution - really cool stuff!]

An interesting use case. Darek (our beloved sys admin - we all bow to him and worship his skills) has recently asked if it’s possible to write a .net application to make a thumbnail of a website. Which is pretty trivial with Windows forms actually.

All you really need to do is drop a WebBrowser on your form and once it’s loaded the page call:

webBrowser.DrawToBitmap(bitmap, bitmapRect);

When it gets tricky is when you want to do it in a console application is a way that can take a shot of multitude of websites provided in a batch file. There is a dirty way of instantiating a whole form, making it show (or not), doing the work and then exiting the Winforms app. Which might probably be enough for a quick solution, but I wanted to publish this piece of code, so I would actually NOT take a pride in something like that.

How is it done the proper way then? Read the rest of this entry »

Popularity: 77% [?]

Posted in .Net Framework, C#, Downloadable, Software Development, Web applications
4 Votes | Average: 4 out of 54 Votes | Average: 4 out of 54 Votes | Average: 4 out of 54 Votes | Average: 4 out of 54 Votes | Average: 4 out of 5 (4 votes, average: 4 out of 5)
Loading ... Loading ...
| 5 Comments »

How dare you, touch my alpha channel!

Why can’t graphic applications get their channels right?

Originally posted on Wincustomize.com

[Updated 11 May 2005] Read at the end of the article.

I’ve been on a quest to improve a skin today and to do so I needed to extract a big archive in a proprietary and not widely supported format and get the images out of it and into the skin. Turned out the first part was not as bad as I expected as I’ve found some tools on the net to do this and Kris helped with the tool to convert the images in the proprietary format into TGA’s. Now here’s where the pain begun.

I needed to have my alpha channel kept in the files but I also wanted to process the files before making them into the skin.

Read the rest of this entry »

Popularity: 26% [?]

Posted in Desktop Customization, Downloadable, Skinning, Software Development
 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 (No Ratings Yet)
Loading ... Loading ...
| No Comments »