Tuesday, May 15, 2007

Vista drain a battery! and Vista Battery Saver is very useful

Yesterday, I posted a beta version of Vista Battery Saver. It made a lot of wind over the statement, that Vista Aero Interface together with Windows Sidebar drain your laptop battery.

The same day at night, Nick White from development team wrote, that he has a hesitation about this statement in Windows Vista Blog. Even Jeff Atwood called me to stop voodooing... But now I have evidence, that approve my doubts. Here is comes.

Dell Latitude D820 with Windows Vista Ultimate on it works one hour more on battery without Aero and Sidebar running

If you do not believe me, here my proves.

image

Here the comparison of 20 minutes of working (regular everyday working) in my computer with and without Vista Battery Saver. It 5% difference of final charge rate. We can solve simple equation to understand, that if my battery loss 16% with Aero and 11% without in 20 minutes, it'll be completely empty within about 2 hours with and within about 3 hours without those fun features. So I was completely right, writing this simple yet useful program.

I realize, that it's possible that the part of sidebar is much more, then the part of aero, but it still makes a lot of sense to use such savers.

For those, who really interested with calculations, raw excel file is attached.

Monday, May 14, 2007

Vista Battery Saver

It's not a secret, that cool WDM (Aero user interface), announced in Windows Vista eat laptops' battery as hungry animal eats it's victim. But what, actually, "eat" your battery - mostly three things: Aero, Sidebar and your wide laptop screen. We have nothing to do with screen, but we can disable either Aero UI and Sidebar, while working on battery. Let me introduce Vista Battery Saver

image

This tinny program will save up to 70% of your battery by disabling those nice, but greedy Vista features. Running in task bar with private workset of 5.5M and 0% CPU it will do all work for you, by enabling and disabling customizable features when power source changed or battery power fall under certain percent.

Actually, I was inspired by similar program of Clint Rutkas and Code4Fun post (as usual, I love those guys) :). But Clint's soft was rather buggy and completely incompatible with Windows Vista Guidelines. This one is completely "Developed for Vista" - ACT 5.0 passed stuff (at least, I think so).

This is not final version, so use it for your own risk and, please, make me know about bugs or "behaviors", that make you sad :)

Download (beta 1) for free (MSI 806KB). You need Windows Vista Home Premium and notebook to run this program.

Friday, May 11, 2007

Two Minutes Timer Windows Sidebar gadget

"If it can be done in less than two minutes, do it now." - tell us wise books about personal productivity. But anyone really knows how long is 2 minutes? Most people had no idea, until now. 

Let me introduce you one of the best personal productivity tools, that help you to implement the Two Minute Rule, one of the simplest, but very powerful techniques.

2m

With this gadget in your Windows Sidebar, it's just a keystroke away. You'll plow through the backlog, close the open loops, reduce reading volume as you learn to scan for value before filing, routing, deleting or recycling. We estimate that a third of your actions take less than 2 minutes.
You'll have fun learning to focus better on how to use your time wisely and prevent getting side tracked, creating a feeling of forward motion and personal control. We've seen gains of up to an hour a day of quality discretionary time just by implementing the 2 minute rule, now made simple with the help of this convenient timer.
Open your sidebar, click on Start Timer button and start working. After two minutes you'll be notified with gentle sound and flashing message "What is your next action?"

Download Two Minutes Timer Windows Sidebar gadget.

Want to learn more about this and other personal productivity rules? Try those books:

1) Robert Crais, Two minutes rule
2) David Allen, Getting things done
3) Pamela Dodd and Doug Sundheim, The 25 Best Time Management Tools

Monday, May 07, 2007

T-Mobile HotSpot at Home

I have T-Mobile phone number and they send me a lot of sales spam information. I used not even see in. It goes directly into Sales Spam folder by skipping inbox. But sometimes, when I'm really tiered,  I'm looking into this folder and sometimes some of emails there catch my attention. The happened today. When such service will be available in Israel? As for my opinion, never. It's it's really sucks...

image

Code snippets for WPF in VS2005

Extremely useful code snippets for DependencyProperty (with and without handler, read-only and not), Routed and Tunneling events were published by SerialSeb and enhanced by Brownie Points. Download and use - this is great time savers.

Programmatically drag and drop

Why I might want to do drag and drop without moving mouse? Well, unit tests - good enough? Anyhow. Today I'll explain quick way to drag&drop from code. Let's create a window with button and textbox. When the button clicked I'll put into D&D bag some string and then put it into textbox by subscribing to Drop event.

  <StackPanel>
<
Button Click="put">Put</Button>
<
TextBox Name="box"></TextBox>
</
StackPanel>

 


And code


public Window1()
{
InitializeComponent();
Drop+=
new DragEventHandler(onDrop);
}


void put(object s, RoutedEventArgs e)
{
DataObject o = new DataObject();
o.SetData(
"kuku");
}

void onDrop(object sender, DragEventArgs e)
{
box.Text = e.Data.GetData(
DataFormats.StringFormat).ToString();
}

 

 

Well done.  Now I should call Ole DragFinish? But hrr, first get handler of my control.. Hr... NO WAY! I'll use DragDrop.DoDragDrop static method. It'll do all the rest. So change put method to something like this to get a result you're waiting for


 void put(object s, RoutedEventArgs e)
{
DataObject o = new DataObject();
o.SetData(
"kuku");
DragDrop.DoDragDrop(this, o, DragDropEffects.All);
}

 


We done.

Sunday, May 06, 2007

How to use System.Drawing.Bitmap (HBitmap) in WPF

Actually, the question is: "How to use nice feature of Resource code generation, presented in VS2005 within WPF". Well, that's not really efficient way, but whatever. As you, probably, know in WinForms (.NET2.0) and Visual Studio 2005 there is code generator for system resources. It makes us able to have intellisense support of VS development environment for loading resources from the application.

Actually, the code generator creates a butch of static properties, that gets objects from application ResourceManager. If you'll take a look into Reesources.Designer.cs file, you'll find there internal static readonly properties like this

internal static System.Drawing.Bitmap p1060981 {
get {
object obj = ResourceManager.GetObject("p1060981", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

 


How to get this and load my images (or any other resources) and use then in WPF this way?


image.Source = ResourceHelper1.Properties.Resources.p1060981;

 


Well, you can not and the main reason is, that it returns System.Drawing.Bitmap, which actually, HBitmap and can not be used directly as image source for WPF. But if you really want try this small helper


public static BitmapSource loadBitmap(System.Drawing.Bitmap source)
{
return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(source.GetHbitmap(),IntPtr.Zero,Int32Rect.Empty,
System.Windows.Media.Imaging.
BitmapSizeOptions.FromEmptyOptions());
}

 


It gets System.Drawing.Bitmap (from WindowsBased) and converts it into BitmapSource, which can be actually used as image source for your Image control in WPF.


This is not very efficient way. It's much better to use Resources management of WPF as described here, but in some cases (this one is not reason :) ) you have to use Forms ResourceManager. One of them, is if you need pixel level access to your bitmap.


Source code for this article