		#region Event #{DelegateName}

		[DllImport(DllName.m_dllName, CallingConvention = CallingConvention.Cdecl)]
		private static extern void Export#{ThisName}Event_Advise#{DelegateName}(IntPtr _native, bool _advise);

		public delegate void Handle#{DelegateName}(
			#{ValueTypePrefix1}#{TypeName1} #{ValueName1},
			#{ValueTypePrefix2}#{TypeName2} #{ValueName2},
			#{ValueTypePrefix3}#{TypeName3} #{ValueName3},
			#{ValueTypePrefix4}#{TypeName4} #{ValueName4},
			#{ValueTypePrefix5}#{TypeName5} #{ValueName5});
			
		private Handle#{DelegateName} mEvent#{DelegateName};
		public event Handle#{DelegateName} Event#{DelegateName}
		{
			add
			{
				if (ExportEvent#{DelegateName}.mDelegate == null)
				{
					ExportEvent#{DelegateName}.mDelegate = new ExportEvent#{DelegateName}.ExportHandle(OnExport#{DelegateName});
					ExportEvent#{DelegateName}.Export#{ThisName}Event_Delegate#{DelegateName}(ExportEvent#{DelegateName}.mDelegate);
				}

				if (mEvent#{DelegateName} == null)
					Export#{ThisName}Event_Advise#{DelegateName}(Native, true);
				mEvent#{DelegateName} += value;
			}
			remove
			{
				mEvent#{DelegateName} -= value;
				if (mEvent#{DelegateName} == null)
					Export#{ThisName}Event_Advise#{DelegateName}(Native, false);
			}
		}

		private struct ExportEvent#{DelegateName}
		{
			[DllImport(DllName.m_dllName, CallingConvention = CallingConvention.Cdecl)]
			public static extern void Export#{ThisName}Event_Delegate#{DelegateName}(ExportHandle _delegate);
			[UnmanagedFunctionPointer(CallingConvention.StdCall)]
			public delegate void ExportHandle(
				#{ValueMarshalAs1}#{ValueTypePrefix1}#{ValueTypeName1} #{ValueName1},
				#{ValueMarshalAs2}#{ValueTypePrefix2}#{ValueTypeName2} #{ValueName2},
				#{ValueMarshalAs3}#{ValueTypePrefix3}#{ValueTypeName3} #{ValueName3},
				#{ValueMarshalAs4}#{ValueTypePrefix4}#{ValueTypeName4} #{ValueName4},
				#{ValueMarshalAs5}#{ValueTypePrefix5}#{ValueTypeName5} #{ValueName5});
				
			public static ExportHandle mDelegate;
		}

		private static void OnExport#{DelegateName}(
			#{ValueTypePrefix1}#{ValueTypeName1} #{ValueName1},
			#{ValueTypePrefix2}#{ValueTypeName2} #{ValueName2},
			#{ValueTypePrefix3}#{ValueTypeName3} #{ValueName3},
			#{ValueTypePrefix4}#{ValueTypeName4} #{ValueName4},
			#{ValueTypePrefix5}#{ValueTypeName5} #{ValueName5})
		{
			#{ValueTypePrefix1}#{TypeName1} sender = (#{ValueTypePrefix1}#{TypeName1})BaseWidget.GetByNative(#{ValueName1});

			if (sender.mEvent#{DelegateName} != null)
				sender.mEvent#{DelegateName}(
					sender ,
					#{ValueConvertBefore2}#{ValueTypePrefix2}#{ValueName2}#{ValueConvertPost2},
					#{ValueConvertBefore3}#{ValueTypePrefix3}#{ValueName3}#{ValueConvertPost3},
					#{ValueConvertBefore4}#{ValueTypePrefix4}#{ValueName4}#{ValueConvertPost4},
					#{ValueConvertBefore5}#{ValueTypePrefix5}#{ValueName5}#{ValueConvertPost5});
		}

		#endregion
