|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Reflection;
namespace DesignSurfaceExt {
public class TabOrderHooker {
private const string _Name_ = "TabOrderHooker";
private object _tabOrder = null;
//- Enables/Disables visual TabOrder on the view.
//- internal override
public void HookTabOrder ( IDesignerHost host ) {
//- the TabOrder must be called AFTER the DesignSurface has been loaded
//- therefore we do a little check
if ( null == host.RootComponent )
throw new Exception ( _Name_ + "::HookTabOrder() - Exception: the TabOrder must be invoked after the DesignSurface has been loaded! " );
try {
System.Reflection.Assembly designAssembly = System.Reflection.Assembly.Load ( "System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" );
Type tabOrderType = designAssembly.GetType ( "System.Windows.Forms.Design.TabOrder" );
if ( _tabOrder == null ) {
//- call the ctor passing the IDesignerHost taget object
_tabOrder = Activator.CreateInstance ( tabOrderType, new object[] { host } );
}
else {
DisposeTabOrder();
}
}//end_try
catch ( Exception ex ) {
throw new Exception ( _Name_ + "::HookTabOrder() - Exception: (see Inner Exception)", ex );
}//end_catch
}
//- Disposes the tab order
public void DisposeTabOrder() {
if ( null == _tabOrder ) return;
try {
System.Reflection.Assembly designAssembly = System.Reflection.Assembly.Load ( "System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" );
Type tabOrderType = designAssembly.GetType ( "System.Windows.Forms.Design.TabOrder" );
tabOrderType.InvokeMember ( "Dispose", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, _tabOrder, new object[] { true } );
_tabOrder = null;
}
catch ( Exception ex ) {
throw new Exception ( _Name_ + "::DisposeTabOrder() - Exception: (see Inner Exception)", ex );
}//end_catch
}
}//end_class
}//end_namespace
|
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.
I started coding in 1984 on a ZX Spectrum. From the Sinclair Basic I jumped straight to C++ (which I use since 1992). I wrote code in assembly 386, ANSI C++ (I love it) and VisualBasic 6.0 (urgh!!!); nowadays I write code in C# 4.0!
I was born in 1968 in Italy and I live in the north west of my country (near Venice). I work as a Project Leader/Senior Developer.
Computer Science interests: I like coding 3D-GameEngine and OpenGL applications.
Sport and hobbies: Martial Arts, Latino Dance, travels, reading and writing novels.