Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / C#

The Favalias Application

Rate me:
Please Sign up or sign in to vote.
4.92/5 (27 votes)
30 Sep 20037 min read 70.8K   2.6K   52  
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.
// Brian DeMarzo
// brian@demarzo.net
#region Copyright � 2003 The Favalias Group
/*
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from the
 * use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not claim
 * that you wrote the original software. If you use this software in a product,
 * an acknowledgment in the product documentation is required, as shown here:
 *
 * Portions Copyright � 2003 The Favalias Group (http://sourceforge.net/projects/favalias).
 *
 * 2. Altered source versions must be plainly marked as such, and must not be 
 * misrepresented as being the original software.
 * 
 * 3. This notice may not be removed or altered from any source distribution.
*/
#endregion

using Favalias.Common;
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using System.Text;
using System.Web;
using System.Windows.Forms;
using Genghis;
using clp = Genghis.CommandLineParser;

namespace Favalias.ConverterAddins
{
	[Serializable]
	/// <summary>
	/// Translates a URL-encoded text string into a text string. Returns output to the clipboard.
	/// </summary>
	public class UrlDecoder : Favalias.Interfaces.IFavaliasAddin
	{
		#region CLP
		[clp.ParserUsage("URL decoder. Generates a URL decoded string from the input string.", AllowArgumentFile=false)]
		private class argsParser : CommandLineParser
		{
			[clp.FlagUsage( "silent mode", Name="s", AllowOnOff = false ) ]
			public bool silent = false;

			[clp.ValueUsage("URL string to decode (if not specified, decode the string copied in memory)", Name = "inputString", MatchPosition = true, Optional = true )]
			public StringCollection inputString = new StringCollection();
		}
		#endregion

		#region Initialization
		public UrlDecoder()
		{
		}
		#endregion
		
		#region IFavaliasAddin Members

		public void Execute(string[] args, Hashtable parameters)
		{
			string inputString = null;
			bool silent = false;

			argsParser parser = new argsParser();
			if ( !parser.ParseAndContinue(args, (string)parameters["aliasName"], Assembly.GetExecutingAssembly()))
				return;

			silent = parser.silent;
			inputString = Utilities.StringCollectionToString(parser.inputString);
			
			if ( ( inputString.Length == 0 ) )
				inputString = Utilities.ClipboardContent;
			
			string outputString = HttpUtility.UrlDecode( inputString );
			if ( !silent )
			{	//MessageBox.Show("The URL decoded string is : \r\n\r\n" + outputString + "\r\n\r\n(It is already copied in memory,\r\n you can paste it with ctrl+V)", "URL decoded string", MessageBoxButtons.OK, MessageBoxIcon.Information); 
				Utilities.ShowAnimateMessageWithTextBox("The URL decoded string is :", outputString, (string)parameters["skin"]);
			}
			Utilities.ClipboardContent = outputString;
		}

		#endregion
	}

	[Serializable]
	/// <summary>
	/// Translates a text string into a URL-encoded text string. Returns output to the clipboard.
	/// </summary>
	public class UrlEncoder : Favalias.Interfaces.IFavaliasAddin
	{
		#region CLP
		[clp.ParserUsage("URL encoder. Generates a URL encoded string from the input string", AllowArgumentFile=false)]
		private class argsParser : CommandLineParser
		{
			[clp.FlagUsage( "silent mode", Name="s", AllowOnOff = false, Optional = true ) ]
			public bool silent = false;

			[clp.ValueUsage( "URL string to encode (if not specified, encode the string copied in memory)", Name = "inputString", MatchPosition = true, Optional = true )]
			public StringCollection inputString = new StringCollection();
		}
		#endregion

		#region Initialization
		public UrlEncoder()
		{
		}
		#endregion
		
		#region IFavaliasAddin Members

		public void Execute(string[] args, Hashtable parameters)
		{
			string inputString = null;
			bool silent = false;

			argsParser parser = new argsParser();
			if ( !parser.ParseAndContinue(args, (string)parameters["aliasName"], Assembly.GetExecutingAssembly()))
				return;

			silent = parser.silent;
			inputString = Utilities.StringCollectionToString(parser.inputString);
			
			if ( ( inputString.Length == 0 ) )
				inputString = Utilities.ClipboardContent;
			
			string outputString = HttpUtility.UrlEncode( inputString );
			if ( !silent )
			{
				//MessageBox.Show("The URL encoded string is : \r\n\r\n" + outputString + "\r\n\r\n(It is already copied in memory,\r\n you can paste it with ctrl+V)", "URL encoded string", MessageBoxButtons.OK, MessageBoxIcon.Information); 
				Utilities.ShowAnimateMessageWithTextBox("The URL encoded string is : ", outputString, (string)parameters["skin"]);
			}
			Utilities.ClipboardContent = outputString;
		}

		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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
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