Click here to Skip to main content
Click here to Skip to main content

The Favalias Application

, 30 Sep 2003
Rate this:
Please Sign up or sign in to vote.
Favalias application enables you to manage your favorites web sites in an XML file and to launch your favorites application using aliases. You can also make your own addins (in any .NET language) to call your own code.

Favalias

Introduction

Favalias application enables you :

  • To manage your favorite websites' URLs. It is independent from a browser since the favorite URLs are stored in an XML file. You could launch a favorite website by clicking in the status area.
  • To launch your favorite application using aliases (typing iis will launch the IIS manager, word will launch MS Word). Thus, you can manage your entire app shortcuts in one application, and you can launch them very quickly (for example: type Win+S to activate Favalias, then type excel to launch MS Excel).
  • To make your own add-ins to call your own code. Your code can be written in any MS .NET language (like VB.NET or C#). For example, typing md5 will call C# code that computes hash codes for file, or typing pwd will call a strong password generator.
  • To do Internet searches. Typing gg will launch a Google search.

Favalias is written in C#, but add-ins can be written in any .NET language. Favalias will run on all MS Windows platforms. It's a WinForm application that uses many powerful features of the .NET platform.

Background

I developed this application first to demonstrate the use of XML and XSL in an application, during my training. Then I added an example of asynchronous web requests (to download the favicons), Regex and added log4net framework. I added a progress bar to show the use of delegates with WinForms, and a UserPreferences class to show how to serialize data. Finally, I added the GenghisCompletionCombo that enables the launch of applications using aliases (like "query" to launch the MS SQL Query Analyzer), and enables add-ins (with dynamic loading of assemblies). This application is like a Swiss army knife for me and I think it could be the same for you!

Using the code

Aliases

The aliases are stored in an XML file by using a DataSet, since it is very easy to read and write an XML file using ReadXml and WriteXml. Using this aliases file, I can detect if I have to launch a command or to do a Google search (any text which is not recognized as an alias will launch your browser to google). The built-in commands are :

  • run anApplication withArguments

    Run an application, you could transmit some arguments.

  • aURL

    If aURL starts with www. or http:// or https://, it will launch your browser to see the specified URL. You can hit Ctrl + Enter to complete the URL (it will add automatically www. and .com like the IE address bar).

  • cls
    To clear this history.
  • You can drag'n drop some text from another application.
  • Ctrl-J and Ctrl-N enable you to navigate in the command history.
  • Favalias uses an auto-complete combobox, so it will show you all your aliases, and you can quickly complete a command by pressing the "tab" key.
  • The Favalias application is shipped with a demo file, examine it to see how to add your own aliases (go to "Options-Edit aliases"). You can use environment variables (like %ProgramFiles% or %SystemRoot%) and %BROWSER% to launch the browser you have configured in the "preferences" menu.
  • You can also launch your aliases using the "aliases" menu.

Addins

Go to "Options-Edit aliases" to choose the addins you want to use. This form displays the applications available in the 'addins' directory.

Addins available with Favalias :

  • gg [keywords] [/lang] [/file] [/cat] [/lucky] [/num] [/site] 
    [/stock] [/link] [/group] [/news]
    Perform a Google search.
  • alarm <message> /ts:timeSpan
    Display a message after the specified timespan.
  • pwd [length]
    Generate a strong password of the given length (for example : "pwd 10" could generate "khN9P%4je1").
  • md5 [file]
    Generate an MD5 hash value for the specified file.
  • sysinfo

        Display the environment variables set on your machine.

  • <FONT color=#000000>htmlenc/htmldec [string]</FONT>

        Encode/decode strings in html strings.

  • <FONT color=#000000>urlenc/urldec [string]</FONT>

        Encode/decode strings in URL-encoded strings.

  • <FONT color=#000000>babel en_fr someTextToTranslate</FONT>
    Translate words using the Babelfish service.
  • <FONT color=#000000>lingo en fr [someTextToTranslate or aURL]</FONT>
    Translate words using the WorldLingo web site
  • <FONT color=#000000>sqlconnec</FONT>
    A SQL Server ConnectionString builder :

Favalias

You can develop your own functions to extend the Favalias application. To do such addins, follow these instructions :

  • Create a class (with your favorite .NET language) ; this class must implement the "Favalias.Interfaces.IFavaliasAddin" interface. To do that you have to reference the FavaliasInterfaces.dll.
  •  Implement the following method : public void Execute(string[] args, Hashtable parameters). "args" will contain the arguments transmitted with the alias, and "parameters" will contain : the alias name used to called this addin ("aliasName" key), the user's browser ("browser" key), the proxy IP and port ("proxyIP" and "proxyPort" keys), the application folder ("appFolder"), the user's favalias application data folder ("appDataFolder"), the addins folder ("addinsFolder").
  • Create a file named "aliases.xml" and add xml configuration for your addin (see the Addins project to see an example). The most important XmlElement is "Command" where you must type "dll assemblyName className". "assemblyName" is the name of your dll (without the .dll extension), and "className" is the full name of your class (with the namespace). You can specify an icon for your addin, use the "icon" element to reference your icon that must be embedded in the dll.
  • Compile your class in a dll and embed the "aliases.xml" file in it (in VS.NET choose "Embedded resource" for the "Build Action" property of the file, or use /resource with your compiler).
  • Copy this dll in the [AppFolder]\Addins folder ([AppFolder] is [ProgramFilesFolder]\Magnon\Favalias by default).
  • Launch Favalias, go to "options-edit addins", select your addin command(s) and try it !

New in v0.5 : you can develop ".exe" addin and specify whether you want to launch it in a new process (use "exe yourExeName /p") or in the same process as Favalias (in a new AppDomain, don't specify /p).

(If you want some examples, see the Addins and SystemInfoAddin projects that are shipped with the source code).

It's quite easy to use addins with Reflection. Just load the assembly and the type, and call the Execute method of the IFavaliasAddin interface :

Assembly a;
a = Assembly.Load(assemblyName); //the runtime checks if it is already loaded
Type t = a.GetType(asssemblyName, true, true);
IFavaliasAddin addin =  (IFavaliasAddin)Activator.CreateInstance(t);
// create arguments
/ ...
// and call the addin :
addin.Execute(newArgs, aliasName);

Favorites

Your favorite URLs are also stored in an XML file. I use it to generate the favorites menu. I sort the favorites using an XSLT style sheet. You can quickly add a favorite by drag'n drop (with the Ctrl key pressed) a link from your browser onto the Favalias form. To manage your favorites, go to "Options-Edit favorites".

To load the favicons (if the web sites provide one), click "Options-Load favicons". It will launch asynchronous web requests to retrieve them. To do that I have used the PriorityThreadPool developed by Stephen Toub. This is a managed ThreadPool which works far better than the .NET framework ThreadPool (which is quite buggy when you attempt to do asynchronous web requests). First I look for a <link rel="shortcut icon"> (using Regex) because some web sites don't use the name favicon.ico. Then I do a second web request to download the favicon ; it's so simple in C# :

WebRequest requestIcon = WebRequest.Create(TheURL); 
requestIcon.Timeout = 15000;
using(WebResponse response = requestIcon.GetResponse())
{ 
    Stream myStream = response.GetResponseStream(); 
    using(Image img = Image.FromStream(myStream))
    {
        saveFavicon(rs.faviconName, img);
    }
}

The saveFavicon method saves the icon in a Hashtable to use it during the menu creation.

Skins

There are two skins available (classic and Matrix). In the next version you will be able to add your own skins to Favalias.

System HotKey

I have added a system hotkey to allow the activation of Favalias using shortcuts (Win+S by default). See the SystemHotKey project for more information. I also added the SingleApplication class to avoid multiple instances of Favalias in memory.

Help Wanted !

If you are interested by developing addins for Favalias or if you'd like to be a beta tester, you're welcome ! Send an email to : jcmag@yahoo.com and I will add you to The Favalias Group (on :http://sourceforge.net/projects/favalias).

Points of interest

I think that DataSets are a very powerful feature of .NET, even if you don't have a database. I have used them to store the aliases and they are very useful to edit data, and load/save this data in XML. I could have used one to manage favorites (I used XmlDocument for them) but I wanted to try different techniques.

The asynchronous features of the .NET framework are also very powerful even if I am quite disappointed by the ThreadPool class.

History

  • 1 Aug 2003 - update downloads

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

About the Author

jcmag
Web Developer
France France
I am an MCSD.NET and MCT. I give a lot of Microsoft Trainings (www.bdcworld.com) in France.

Comments and Discussions

 
Generalnice combination of technologies.. Pinmemberashley_vg31-Jul-03 20:54 
GeneralRe: nice combination of technologies.. Pinmemberjcmag31-Jul-03 23:04 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 1 Oct 2003
Article Copyright 2003 by jcmag
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid