Home .NET Easy navigation in Windows Explorer and Total Commander

Easy navigation in Windows Explorer and Total Commander

by admin

Have you ever thought that navigation in Windows could be much more convenient? Why not add a feature similar to the class navigation in many modern IDEs, where a shortcut drop-down list displays folders with the name you want, like this :
Easy navigation in Windows Explorer and Total Commander
Once I thought about it, I wrote a little app called "Navigation Assistant, " pictured above.It is available here , it’s open source, it’s free, and it’s distributed under the MIT license. I hope someone will find it useful.

Why is this necessary?

Here are the disadvantages of navigation in Windows Explorer and Total Commander, which I’m sure many people are frustrated by :

  1. if the nesting depth of the folder you are looking for is very deep, you need to make many mouse clicks
  2. The default search in Windows Explorer is incredibly slow. Besides, to use it you have to launch explorer itself, click the search field, type the whole name of a folder or file, and wait a long time
  3. Total Commander has prompts for typing paths in the address bar, but you have to type either the full path or a relative path (relative to the current folder), which is inconvenient

That’s why I wrote "Navigation Assistant", which works similarly to class or file navigation in many modern IDEs: Ctrl-Shift-N and Ctrl-Shift-N combinations in JetBrains products (ReSharper, IDEA, PhpStorm, WebStorm), Ctrl-Shift-T in Eclipse.
A bonus of using this program is a better directory structure. Many developers, especially those who have read Code Complete, are aware that the brain does well with 7 ± 2 objects in working memory; so just as it is useful to limit the number of fields and methods in a class, it is useful to limit the number of subdirectories in a given directory.
As things stand now, this can only be achieved at the cost of awkward navigation. With Navigation Assistant, you no longer have to fear large nesting of directories.

How to use this?

So far only fast folder navigation is supported, not file navigation.
To quickly get to the folder you want, in Windows Explorer or Total Commander (or in any other, but then a new Windows Explorer will be instantiated for navigation) press a special keyboard shortcut (by default Ctrl-Shift-M, but you can change it in the settings). The main window of the application will appear :
Easy navigation in Windows Explorer and Total Commander
Start typing the name of the folder you would like to reach.
Killer feature: you don’t have to type the whole folder name; for example, you can type "documents and" to get to Documents and Settings. Moreover, you do not have to type the whole word "documents", "doc and" is enough (hello, JetBrains!); also, you do not have to type the folder name from the first word: "and settings" will do. Especially for developers, the pascal/camel case is supported: the search line "nav assist" will also include the folder "NavigationAssistant".
As a result of these manipulations a list of suitable directories will appear on the screen :
Easy navigation in Windows Explorer and Total Commander
You can either select the desired item with the mouse or use the up/down keys and click Enter (the input focus can remain in the text field during this time).
If you don’t like the window, you can quickly minimize it to tray with Escape key.
If you call the program not in Windows Explorer and not in Total Commander, it will open a new Windows Explorer window (with the necessary folder); in the settings you can change the default navigator to Total Commander.

What else is in it?

There is also a settings window where you can change

  1. list of programs to support improved navigation (e.g. disable Total Commander)
  2. default navigation program
  3. key combination to call the Navigation Assistant window
  4. specify in which directories to search (for example, only C:Users or only D:)
  5. you can also exclude some directory names from the results (e.g., bin, obj, .svn)
    (more precisely, any path containing the folder bin will be excluded; note that these are actually regular expressions, so you could specify something like binS*)
  6. set the default boot (recommended because it will not refresh the internal directory cache at each startup)

There are tooltips for all options. To get to the settings, just right click on the tray icon.

How it is done

The utility is written in Microsoft .Net 3.5 using WPF technology, so it should work wherever .Net 3.5 is present.
The installer is written with the help of Inno Setup which I wildly recommend to anyone who writes installers : it’s much better than WiX, Install Shield, Visual Studio Installer, because it

  1. free and free
  2. modular (not tied to Microsoft technologies)
  3. transparent (only the text script is edited, no visual programming, like in Visual Studio Installer)
  4. As a consequence, installer files are not recreated with every change-no version control issues
  5. flexible (supports Pascal/Delphi scripting). Last time I saw Delphi about 7 years ago, in my first year of college, but the advantages of InnoSetup more than compensate for this drawback
  6. Oh yeah, it magically creates the same installation file for x32 and x64 versions

A comparison of the installers can be found, for example, here
There are several non-trivial moments in the code :

Reaction to global keystrokes

In order to show the Navigation Assistant window on time, you need to listen for keystrokes globally (i.e. in all applications). .Net doesn’t allow this out of the box. So I used the code from here (although there are several other solutions, just google the phrases global hooks/ global hotkeys).

Setting focus to an inactive application

After we found out that in some window the cherished key combination was pressed, we need to show Navigation Assistant and also set focus to it (make it active, that is).
Yes, there is a method in WPF Window.Activate which calls the WinApi function SetForegroundWindow , and therefore has all its limitations. Namely, if your application is inactive when the method is called, the window will not be made working, i.e. the focus will remain in the old window. Actually, this is good to keep malicious programs from suddenly changing current focus and interfering with user’s work in every possible way. But in our case we want to bypass this limitation.
The solution helped right here , although there are several others ( times , two ), but they didn’t work so well.

Integration with Windows Explorer

In order to get a list of open Windows Explorer windows, this has been borrowed this code By having a wrapper over the COM object, you can easily change the current path in this explorera window.

Integration with Total Commander

Integration with Total Commander is done with command line options , first of all /O, which sets the path passed with it not in a new Total Commander instance, but in an already opened one (if there is one).

Architecture

A standard multi-tiered architecture is used (there is an excellent review at " Domain Driven Design Quickly Online " by Avram and Marinescu)

  1. UI Layer
    1. Views
  2. Presenters Layer
    1. Presenters
    2. Presentation Services
    3. View Models
    4. View Model Mappers
  3. Domain Model aka Business Layer
    1. Domain Services
    2. Domain Data Objects (plain Data Transfer Objects)
  4. No Data Access Layer 🙂

At first I tried to use the Model-View-View Model template, but then I switched to
Model-View-Presenter for the following reasons :

  1. MVP adds an extra level of abstraction to Presenters, and without it all the logic ends up in View Models, and the latter become unnecessarily large
  2. This logic should semantically not belong to View Models (single responsibility, to-se)
  3. Unable to use interface-driven development (for Views)
  4. As a consequence, the UI layer becomes a mess (in the sense that there is no separation of duties, modularity, clear interfaces)

So now the Model-View-Presenter is used, and the UI and data are linked via View Models (WPF Binding), with View Models

  1. or transferred to methods of view interfaces from presenters
  2. or are instanced by the representations themselves

Basic functionality is covered by tests (nUnit and Moq are used).

Problems

There are probably more bugs in the app that have not been found.
Also, I’m not a big icon-drawer, so the icon in the system tray on a white background looks angular, as if without anti-aliasing; in all other cases, the icons look, to me at least, acceptable (but I won’t turn down any help or advice).
The first time you run it, it will take a while to find all the folders on the user’s computer, so you will have to wait a few minutes.
If Navigation Assistant was not shut down the last time the computer was turned off, or was not started automatically when the system started, there is no way to tell if the current directory cache is up to date; so this cache will be updated in an extra thread, and the last saved directory cache (which may not fully match the current file system) will be used until this process is complete.
Yes, .Net in general and WPF are slow and resource intensive, but you have to put up with that.

Conclusion

So, I hasten to share a small utility for easy navigation in Windows Explorer and Total Commander. I hope someone will find it useful. Also, maybe a brief overview of the technical solutions will be useful.
Links again : to installer , to the project on google code (using svn as most people are likely to know).
Source code is open, the application is free, and distributed under the MIT license.
Thank you all!

You may also like