• Firefox & IE - Copy Context Menu Plugin

    I have created a set of browser plugins that are pretty helpful for developers and I thought that I should share them. I have created basically the same plugin for both IE and Firefox. What it does is add a "Copy As Html" and "Copy As Plain Text" to the context (right-click) menu. It is useful if you want to copy the text or underlying html from a web page into word, outlook or visual studio. Below is a setup file that sort of automates the installation. It will install the IE plugin completely and it will copy the file for the Firefox plugin. You will have to manually open the firefox plugin using firefox and choose "Install" to complete the firefox plugin installation. The plug-in should be installed here: "C:\Program Files\Fillmore Technology Group\Utilities\Firefox\copyMenu_- 1.3.0-fx.xpi", but the actual location will be on the bottom of the last form in the setup wizard. Since there are plenty of resources on the web that explain how to program these, I am not going to go into any detail on how it was accomplished. I will say that the end result was pretty simple to do, but finding all the information took a little time.

  • If you are like me, then you enjoy traveling into the future from time to time. The biggest problem that I faced is when I was away from my time machine but I needed to go to the future. In order to help facilitate my time traveling I created a web-based time machine. Now I can travel into the future from any place that has an internet connection. 

    The time machine is currently in beta so you can only go short distances into the future at a time. You can use it free of charge by going to: BestTimeMachineEver.com 
  • .Net Remote Script Request

  • Have you ever wanted an easy way to call a server side method from javascript? If so this class may be just what you need. 

    I have created a simple and easy to use method for accomplishing this task. All you have to do is have your webform inherit from the remote script page, make your call using a simple javascript object (will be included automatically), and when you execute the request in javascript the OnRemoteScriptRequest event will be raised in your server side code, you then process the request and write the result out on the response stream. The result will be returned by the javascripts execute method. 

    This .Net class library uses a combination of C# code and javascript to accomplish the task in an easy to use manner. The call uses Microsoft.XMLHTTP, Msxml2.XMLHTTP or XMLHttpRequest objects (depending on the browser) to do the underlying call back to the server. Because of this it will work in all recent IE and Mozilla based (Firefox, Netscape, Mozilla, etc.) browsers. 

    Here it is step by step
    1. Include a reference to RemoteScript.dll
    2. Have your webform inherit from the remote script page: 
      public class WebForm1 : RemoteScript.Pages.RemoteScriptPage
    3. Add the event handler in the InitializeComponent method 
      this.OnRemoteScriptRequest += newRemoteScript.Pages.RemoteScriptEventHandler(RemoteScriptTest_OnRemoteScriptRequest);
    4. Add the event handler method 
      private void RemoteScriptTest_OnRemoteScriptRequest(object sender, ...
    5. After you add your code to the event handler you will be able to call it from javascript using the RemoteScriptRequest javascript object, Example:

      objRS = new RemoteScriptRequest();
      strReturnValue = objRS.Execute();
  • Simple C# RSA Encryption Class

  • Well, you can figure this out yourself, use it if you like, tell me how much it sucks, what ever you want. 

    What it does is takes data and encrypts it using DES encryption and then encrypts the DES Keys using RSA and stores everything in an XML string to be saved for later decryption. There are also classes to hold the encrypted data and to create and save the RSA keys. This seems to be a pretty good solution for encrypting data or files. 

    I wrote this code and am now posting it because I did not find any simple snippets on the web for encrypting data in C#. Everything seemed too complicated or was not robust enough. I am sure that many people may have problems with this code or the lack of explaination in the code, but oh well... Its here for those who want to look it over. Remember, use at your own risk! 
  • C# LateBound COM

  • I made a very simple wrapper for calling com objects in c# and I thought you may find it useful. Currently there are only a couple methods, but they are the most useful items. 

    Sample usage: 
    //Create object object myComObject = ComUtil.CreateObject("SomeObject.SomeClass"); 

    //Call Method
    object[] parameters = new Object[]{paramValue1, paramValue2, paramValue3, paramValue4}; 
    ComUtil.CallMethod(myComObject, "MethodName", parameters); 

    //Get a property
    Int16 returnValue = (Int16)ComUtil.GetProperty(myComObject, "PropertyName"); 

    //Set a property
    ComUtil.SetProperty(myComObject, "PropertyName", value); 

    //Call a method with a ByRef parameter (recordset)
    ADODB.Recordset rs = null;

    ParameterModifier byRefParamMod = new ParameterModifier(1);
    byRefParamMod[0] = true;

    ParameterModifier[] pmArray = {new ParameterModifier(1), byRefParamMod, new ParameterModifier(1),new ParameterModifier(1)}; 

    object[] parameters = new Object[]{paramValue1, rs};
    ComUtil.CallMethod(myComObject, "MethodName", parameters, pmArray);

    //Call a method with a return value
    ADODB.Recordset rs = (ADODB.Recordset)ComUtil.CallMethod(myComObject, "MethodName", null); 
  • QueryString Encryptor HTTPModule

  • I wrote an HttpModule that Encrypts querystrings.  This module is seamless to the web developer. You can create html that looks like this: myPage.aspx?id=1&customer=2 and the source on the client will automatically be converted to this: myPage.aspx?eqs=KS%2bthrckechBKT%2bZ8IB44Bz3qvW3853f. Then to access the value in the code behind page you would use QueryString["id"] or QueryString["customer"].

    To install it add QSHttpModules.dll to your bin directory and then add the following to your web.config (any where in <system.web>):

    <add type="QSHttpModules.QueryStringEncryptor, QSHttpModules" name="QueryStringEncryptor" />


    The module does this by finding the links and replacing them with the encrypted version as the page is sent out to the client. Then on every request the module looks for an encrypted querystring, if found it decrypts it and rewrites the url.

    The code is listed below, but you can also download it from my message board at:http://csharpboard.com/ShowPost.aspx?PostID=44. This module of course takes some overhead to process and it is not recommended to be used as a full security feature. Rights checking should always be in place. But, if a little cpu time is worth hiding the contents of your querystring, this may be for you.

    As always, use at your own risk.

  • Javascript Color Picker

  • I wrote a javascript color picker. I know that there are plenty out there, but I just did not like the way they looked or worked very much. So, I decided to add one more color picker to the world. The down side to this color picker is that it uses external files, but to me it is worth it. It has a photoshop feel that I like. 

    You will find a working sample below and you can download the code and a test page here. As always you will have to figure the code out yourself and you must use at your own risk. 
  • C# - Loading and creating an object instance from a file

  • This sample is pretty simple. It is basically loading a latebound object. I am not sure how often most people will have to do this, but I did so I will share it. 

    This method does not do that much. It will load an assembly from the provided file path and then attempt to create an instance of the type specified. If an empty string is provided for the type, it will create an instance of the first type in the assembly. If there is an error then null is returned. 

    Use: myType myObj = (myType)CreateLateBoundObjectFromFile(@"c:\myFilePath.dll", "myType"); 
  • .NET Zip Library #ziplib (SharpZipLib)

  • I have used the SharpZipLib for some time now and it is great. It's easy to use and does everything that you may need; Zip, GZip, Tar, etc. 

    Lately, I have seen quite a few third party .Net zip components for sale and its hard for me to believe that someone would buy a component when such a good one exists for free. It must be that not enough people know about this free library. Well, here it is:http://icsharpcode.net/OpenSource/SharpZipLib/Default.aspx 




Managed DirectX - Direct3D Windows Control written in C#

I created a windows control to hopefully simplify adding Direct3D to .Net applications, it is written in C#. This control has a lot of functionality, but it by no means has everything that I intended on putting in. It is my first real Managed DirectX project so be a little forgiving if you find something that is not done just right. 

The purpose of this control is to provide a Direct3D surface that can be added to any .Net windows form. It has a lot of features that can do most of the busy work for you. One thing to note is that this library is not intended for hard core games, but more for windowed applications. 

This library has been sitting around for the last six months unfinished, but still in a good working state. I have been to busy with other things to work on it, so I decided to put it up here in case some one could learn from it. I know I learned a lot making it. 

The library consists of a user control which handles the render loop, direct3d initialization on so on, as well as a bunch of mesh classes and a camera class. I don't have a lot of time to go over how to use it but included in the download are four sample applications that use the control, so you should be able to figure it out. 

To use it all you have to do is add the control to your tool box. Add event handlers for the OnSceneUpdateReady and OnRender events and then you are ready to go. By default a camera class will be created and set in the controls ActiveCamera property. The default settings is to automatically add the transforms for the active camera before the OnRender event is fired, however this is configurable. The OnSceneUpdateReady event is fired before the OnRender and is intended for updating the scene and doing all of your program logic. The OnRender event is fired between the BeginScene and Present methods and is intended for rendering the objects. 

The included mesh objects all implement the ID3DMesh interface and can be rendered using the Render() method. There is a RenderSettings property that you can use to set some render settings such as wireframe, solid, autoset transform, and so on. The ID3DMesh interface also has a method for rendering planar shadows as well as a bunch of other stuff. 

One of the best features of the control is that it enumerates all the supported hardware configurations on start up and stores all the combinations in a DataTable, which can be used for setting the best device settings. In addition to this there is aShowDeviceSettingsForm() method which will open a dialog that will allow the user to choose from the supported settings. It can be seen in the Mesh Viewer screen shot below. The Mesh Viewer is one of the test apps that is included in the download.