Archive for the ‘Szótár’ Category

Linq is cool.

var types = from type in System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
	let attr = Attribute.GetCustomAttribute(type, typeof(PreferencePageAttribute), true)
	where attr != null
	select new { Attribute = attr as PreferencePageAttribute, Type = type };
Posted on Sunday, January 13th, 2008 in .NET, Code, Szótár | No Comments

Vista-style menus in .NET

Update: you might want to check out the WindowsFormsAero project, which uses an improved version of this code, if you’re looking for a way to get vista-like/aero-style menus for System.Windows.Forms. (July 2008)

Ever noticed that .NET-style menus are ugly?

Windows Vista comes with a new style of menus (which allow images, too), and a few updates to the UxTheme API, including the ability to render these themed menus. When the .NET framework was designed, however, this functionality wasn’t available; and you can see this clearly by looking at a default MenuStrip.

But ToolStrip allows you to give it a new renderer (via its Renderer property), and you can write a ToolStripRenderer that draws menus using UxTheme with not too much effort.

And that’s exactly what I’ve done, and you can have the source code. Do what you like with it. It only really works with menu bars and context menu bars, because I didn’t need it for anything else.

You can apply it in one of two ways, both pretty simple.

  • toolStrip1.Renderer = new NativeToolStripRenderer();
  • NativeToolStripRenderer.SetToolStripRenderer(menuStrip, contextMenuStrip);

Here’s some screenshots:
Using Aero (Vista) Theme (120dpi)
Using Luna (XP) Theme (120dpi)
Using Windows Classic Theme (120dpi)

If you do use this, here are some scenarios to test:

  • Starting with Aero on, and turning it on/off and switching into classic mode a few times
  • Starting with Aero off, and turning it on/off and switching into classic mode a few times

In a similar vein, there is also a WindowsVistaRenderer on The Code Project, which draws the sort of dark toolbars you can see in Windows Media Player 11, Windows Photo Gallery, etc.

Comments welcome!
- Lee

Posted on Sunday, December 9th, 2007 in .NET, Code, GDNet, Szótár | Comments Off

PropertyGrid

I quite like PropertyGrid. Here’s a simple dictionary editor made by binding a PropertyGrid to a DictionaryInfo object. :)

Dictionary Info Editor Selecting an Encoding

Posted on Thursday, December 6th, 2007 in Code, Szótár | Comments Off