Click here to Skip to main content
15,890,438 members
Articles / Programming Languages / C#
Article

LeerTools: A suite of controls, dialogs and other useful methods

Rate me:
Please Sign up or sign in to vote.
3.71/5 (7 votes)
30 Aug 200410 min read 78.4K   1.5K   49   13
Comprehensive library of controls, dialogs and useful methods

Various screen shots

Image 1

Image 2

Image 3

Image 4

Introduction

After programming in BASIC, FORTRAN, Assembly, PLI, C, and then C++ for a combined 30+ years, I finally decided to check out the 21st century and write my first meaningful application in .Net. It was going to be a variation of an personal information manager that I had put out as shareware a number of years ago. At first I was enamored with the seemingly endless amount of classes, controls and documentation, and the ease at which one could quickly develop in this new environment. However, it did not take long to realize that there were many deficiencies in the way some of the controls operated, holes in the documentation, as well as outright bugs. As I developed my new application there were many times where I just wish something worked differently.

The first small annoyance was how the progress bar painted the bar in little separate boxes instead of a smooth continuous bar and didn't incorporate a percent complete indicator. Then there was the inability to change colors in the predefined dialogs such as the PrintPreviewDialog and others. Before long I began rolling my own versions of various controls so that I felt I had more control (no pun intended) over how they worked. And, of course, I would have the source code to fix problems and enhance the controls as I had done for years when the MFC source code was freely distributed.

One of the main areas I wanted to coordinate was simply to be able to pick a color scheme for all my controls and somehow everything in the application could easily use that color scheme. Then there were the many simple little things that I wanted that were just not available in the .Net controls, such as the ability to paint a picture in a frame but still get keystroke events (I use that in my LeerColorPicker to allow keystrokes to move the crosshairs around.) And then there was that nasty Interop thing that we needed to use in order to do things that just was not included in the first two iterations of the Framework. I wanted to write much of that stuff once so I wouldn't have to think about it again.

So what are LeerTools?

Simply put, they are a collection of controls, dialogs, methods and some Interop wrappers that worked the way I felt I needed to write the quality of application I hoped to create. And having been a user of some open source code in my career, I decided to give back to the development community and release this suite of tools. Although many of the controls are basically replacements for some things that are available in .Net, either using or just reviewing the code can prove to be useful in several ways:

  1. Some of the controls offer features that are not available in the .Net equivalents.
  2. Some of the controls just don't exist in .Net Framework.
  3. Having the source code makes it easier to customize the controls to your liking.
  4. The concept of the LeerSkin to have a consistent color scheme can certainly be broadened to provide a total look and feel across the controls.
  5. Buried throughout may be interesting examples of how to do certain things and/or workaround known problems.
  6. The collection of additional Methods may save some time in reinventing the wheel.

Note that most of the LeerTools controls do not inherit from the .Net counterparts. For the most part they inherit from very basic classes such as Control, UserControl and NativeWindow.

What is included in LeerTools?

Controls:

  • LeerButton - A button control that adds features such as a detent style, separator style (for use in LeerControlBar), and an optional drop-down arrow to be used for displaying an additional context menu (similar to the Back button in Internet Explorer.)
  • LeerContextMenu - My version of a context menu. All LeerTools menus are based on an ILeerMenu interface that can make it easy to design other parents for a set of menus. These context menus have several styles, and include an optional label appearing alongside a dropdown menu (a feature I had seen in some other CodeProject article.)
  • LeerControlBar - This control provides what the MFC ControlBar did, but the .Net ToolBar> sorely left out. That is, it can be the container for any other type of control that fits within the boundaries of the bar, not just variations of a button. This is one of my favorite controls as none of the toolbars in my application are strictly buttons. A neat feature of this control is that it will optionally automatically create a dropdown list for button controls that can't be seen because the user has shrunk the window containing the control bar. In addition, the LeerControlBar supports a vertical orientation in addition to the standard horizonatal orientation. The
    LeerFilePicker
    
    uses the vertical form to display the "favorites" buttons.
  • LeerExplorer - This control is actually derived from the .Net TreeView. It provides a standard tree view of the computer's file system, must the same as you would see in Windows Explorer program.
  • LeerFolderCombo - A variation of LeerExplorer that presents a dropdownlist look at the shell's file system to facilitate selecting a folder. It performs like the folder drop down in the common file dialogs we all have come to love.
  • LeerMenuBar - This is similar to the MainMenu .Net control. It does not, however, need to reside at the top of a form. It can be placed anywhere on a form and can be any width. Similar to the LeerControlBar, the LeerMenuBar can automatically create a dropdown to the right of the bar with menu items that cannot be seen when a form shrinks too small to show all the menu items.
  • LeerPictureBox - A simple control designed to display an unscaled image in its center. I created this control so that I can get keyboard events from a control that is displaying a picture, which I could not get from a .Net
    PictureBox
    
    . I use this control, for example, in my LeerColorPicker.
  • LeerProgressBar - A non-glamorous progress bar that shows a smooth bar (rather than a series of boxes), and allows a percent complete to be displayed as well.
  • LeerSkin - A set of colors properties that can be used by all other LeerTools controls and dialogs. The Methods.PropogateSkin method lets a form propogate its skin to all compatible LeerTools controls that are contained within its boundaries.
  • LeerTabBar - This control is like a TabControl but without the pages. It shows just the tabs so that you can have the functionality of tabs but not be limited to the metaphor of "one tab to one dialog (TabPage)."
  • LeerTabControl - This is a more traditional tab control that consists of an underlying LeerTabBar where each tab is associated with a TabPage.

Dialogs:

  • LeerCharacterPicker - The LeerCharacterPicker dialog allows you to select any character in the range range 32-255 from within any available system font. It is useful when you need to add a special character into a document and you do not know the character code or do not know how to enter the keystrokes to get that character.
  • LeerColorPicker - The LeerColorPicker is a compact and powerful color selection dialog. Its crosshair color selector (one of three ways to select a color) is based on the Hue/Saturation/Brightless(or luminescence) presentation (see http://www.nebulus.org/tutorials/2d/photoshop/color/color2.html for a discussion of these terms.), which in my opinion, makes it possible to see a wider selection of colors making it quicker to get close to the color you wish to choose. It also has some nice features such as displaying basic and/or web-safe color wells for quick color picking, the ability to choose a web-safe color close to the custom color you have selected, and easy to use retention of custom colors selected, shows hex color values if you want to use those colors in HTML pages, and more.
  • LeerFilePicker - LeerFilePicker is a replacement for the .Net OpenFileDialog using all LeerSoft components. It uses a LeerFolderCombo to select the folder, a vertically oriented LeerControlBar to display common locations a user might browse to, and a ListView to display the individual files. The LeerFilePicker contains most of the elements in the
    OpenFileDialog
    
    except some that are included as properties, but not implemented. The benefits of using the LeerFilePicker is that it's appearance can be controlled by a LeerSkin (the OpenFileDialog is closed and therefore you get what you get.)
  • LeerFolderPicker - Presents a dialog that allows a user to select any shell folder. It is not the prettiest of the LeerTools, but gets the job done.
  • LeerFontPicker - Displays a dialog from which you can select the following attributes of a font: name, style, size, strikeout/underline, text and background colors.
  • LeerPrintPreviewDialog - Displays a print preview for a .Net PrintDocument. The main reason for the existence of this dialog is to be able to control the skin look and feel of the dialog, which cannot be done with the built in PrintPreviewDialog. Not to mention I wanted source so that I could choose to change its behavior.

Other goodies:

  • A Methods class that contains a few dozen [hopefully] helpful routines, such as a routine to fetch the icon for a file from the shell, and a routine that displays a simple yes/no or ok/cancel type of message box but uses the LeerSkin for look and feel.
  • A MultiMedia class that provides for playing and/or recording audio files. It currently will play almost any format, but the implementation provided only records wav or wma files. The MultiMedia class is based on the excellent BASS sound library from un4seen developments (http://www.un4seen.com), which is ONLY free to use for non-commercial purposes. They have various reasonable licensing prices for commercial packages, and their software contains and enormous amount of additional functionality that LeerTools does not expose. The MultiMedia class is actually an implementation of the LeerTools' IMultiMedia interface so that you can rewrite the class with any other library you may have should you need to use this in a commercial application. LeerTools only internally uses the MultiMedia class for playing a sound when a popup menu pops up.
  • LeerTools contains wrappers for some of the frequently used interfaces, such as the IShellFolder interface used to get information about shell objects.
  • LeerTools also has a large set of enumerations, structures and interop definitions for may Win32 functions.

Using the code

The best way to get started is to unzip the application, compile the solution (please use .Net Framework 1.1 as there are a few bugs that were fixed in 1.1 that I rely on), then add the LeerTools.dll to your VS design tools. If you like, you might create a new section for LeerTools to keep the new controls separate. The sample application is not pretty nor heavily commented, but does demonstrate a good deal of the functionality. The LeerTools source files, however, are extremely heavily commented and I have supplied a reasonably accurate LeerTools.chm documentation file created with NDOC.

Note: LeerTools was written entirely in C# on Windows XP Pro, and tested both in the included sample application as well as in a large scale application that makes moderately heavy use of all the controls. However, there has not been any formal beta testing. There is a lot of code, some of which is depends quite a bit on Windows messaging and it may take a few versions to get any kinks out. In addition, I do not know any reason why they would not be usable in Visual Basic.Net, but I do not use that language and therefore have not tested it. I welcome any feedback (good or bad), requests for changes/enhancements, bug fixes, bug reports or questions. Enjoy.

Known issues

The LeerFilePicker can be a little slow when filling the ListView with the contents of a folder that has a large number of files in it. It may be possible to speed it up if I tapped into the Indexing Service.

History

  • Version 1.1 is the first version released to the public.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
I graduated MIT with a BSEE in 1972 and began my software development career thereafter. In 1979 I founded Dynamic Microprocessor Associates where I developed numerous software applications in the early days of the PC including the 1st general purpose communications program for the PC (ASCOM) and the first multiuser database development system (FORMULA IV). In 1985 I developed the remote control program pcANYWHERE which is now a product of Symantec Corporation. DMA also co-developed Novell's Netware Access Server (NAS).


Currently I divide my time between developing C# applications and my pastime of bowling.

Comments and Discussions

 
GeneralDesign Issues Pin
UnderscoreC3-Jul-06 14:20
UnderscoreC3-Jul-06 14:20 
GeneralRe: Design Issues Pin
leerjet3-Jul-06 17:05
leerjet3-Jul-06 17:05 
GeneralRe: Design Issues Pin
UnderscoreC3-Jul-06 17:26
UnderscoreC3-Jul-06 17:26 
I didn't mean to come across as an ass. I do that sometimes though. I actually hadn't looked through the entire code yet and thought that the design of the skinning system prevented the user from editing the colors themselves. My bad.

I think that your code itself is pretty good and if I can fix the issues I have with the code (minor issues, really) then I'll probably end up using it. I have about three different controls (including yours) I'm looking at to figure out which gives the best combo of functionality and ease of use and can be run through FXCop with a miniume of issues.

Sorry for the misunderstanding, again, I didn't mean to attack you.
GeneralRe: Design Issues Pin
leerjet4-Jul-06 0:59
leerjet4-Jul-06 0:59 
GeneralRe: Win32 dependancy Pin
leerjet4-Oct-04 3:37
leerjet4-Oct-04 3:37 
Generalre Bass library dependency Pin
BillWoodruff8-Sep-04 2:02
professionalBillWoodruff8-Sep-04 2:02 
GeneralRe: re Bass library dependency Pin
leerjet14-Sep-04 8:35
leerjet14-Sep-04 8:35 
GeneralLeerSoft?? Pin
lzqwj1-Sep-04 22:44
lzqwj1-Sep-04 22:44 
GeneralLibraries Pin
kuerbis31-Aug-04 9:07
kuerbis31-Aug-04 9:07 
GeneralRe: Libraries Pin
leerjet31-Aug-04 10:13
leerjet31-Aug-04 10:13 
QuestionBass.dll? Pin
Furty31-Aug-04 2:13
Furty31-Aug-04 2:13 
AnswerRe: Bass.dll? Pin
leerjet31-Aug-04 3:26
leerjet31-Aug-04 3:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.