context: // auto generated with nant generateWinforms from {#XAMLSRCFILE} and template windowTDS
  //
  // DO NOT edit manually, DO NOT edit with the designer
  //
  {#GPLFILEHEADER}
  using System;
  using System.Drawing;
  using System.Collections;
  {#IFDEF TABPAGECTRL}
  using System.Collections.Generic;
  {#ENDIF TABPAGECTRL}
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Reflection;
  using System.Data;
  using Ict.Petra.Shared;
  using System.Resources;
  using System.Collections.Specialized;
  using GNU.Gettext;
  using Ict.Common;
  using Ict.Common.Verification;
  using Ict.Common.Remoting.Shared;
  using Ict.Petra.Client.App.Core;
  using Ict.Petra.Client.App.Core.RemoteObjects;
  using Ict.Petra.Client.App.Gui;
  using Ict.Petra.Client.MCommon;
  using Ict.Common.Controls;
  using Ict.Petra.Client.CommonControls;
  using Ict.Petra.Client.CommonForms;
  {#IFDEF SHAREDVALIDATIONNAMESPACEMODULE}
  using {#SHAREDVALIDATIONNAMESPACEMODULE};
  {#ENDIF SHAREDVALIDATIONNAMESPACEMODULE}
  {#USINGNAMESPACES}
  
  namespace {#NAMESPACE}
  {
  
    /// auto generated: {#FORMTITLE}
    public partial class {#CLASSNAME}: System.Windows.Forms.Form, {#INTERFACENAME}
    {
      private {#UTILOBJECTCLASS} FPetraUtilsObject;
  {#IFDEF DATASETTYPE}
      private {#DATASETTYPE} FMainDS;
  {#ENDIF DATASETTYPE}
  {#IFDEF MASTERTABLE OR DETAILTABLE}
      private DataColumn FPrimaryKeyColumn = null;
      private Control FPrimaryKeyControl = null;
      private string FDefaultDuplicateRecordHint = String.Empty;
  {#ENDIF MASTERTABLE OR DETAILTABLE}
  
  {#IFDEF UICONNECTORTYPE}
  
      /// <summary>holds a reference to the Proxy object of the Serverside UIConnector</summary>
      private {#UICONNECTORTYPE} FUIConnector = null;
  {#ENDIF UICONNECTORTYPE}
  
  {#IFDEF TABPAGECTRL}
      private SortedList<TDynamicLoadableUserControls, UserControl> FTabSetup;
      {#IFDEF DYNAMICTABPAGEUSERCONTROLDECLARATION}
      private event TTabPageEventHandler FTabPageEvent;
      {#ENDIF DYNAMICTABPAGEUSERCONTROLDECLARATION}
      {#DYNAMICTABPAGEUSERCONTROLDECLARATION}
      
      /// <summary>
      /// Enumeration of dynamic loadable UserControls which are used
      /// on the Tabs of a TabControl. AUTO-GENERATED, don't modify by hand!
      /// </summary>
      public enum TDynamicLoadableUserControls
      {
          {#DYNAMICTABPAGEUSERCONTROLENUM}
      }
  {#ENDIF TABPAGECTRL}
  
      /// constructor
      public {#CLASSNAME}(Form AParentForm) : base()
      {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        #region CATALOGI18N
  
        // this code has been inserted by GenerateI18N, all changes in this region will be overwritten by GenerateI18N
        {#CATALOGI18N}
        #endregion
        
        {#ASSIGNFONTATTRIBUTES}
        
        FPetraUtilsObject = new {#UTILOBJECTCLASS}(AParentForm, this, stbMain);
  {#IFDEF DATASETTYPE}
        FMainDS = new {#DATASETTYPE}();
  {#ENDIF DATASETTYPE}
        {#INITUSERCONTROLS}
  {#IFDEF ACTIONENABLING}
        FPetraUtilsObject.ActionEnablingEvent += ActionEnabledEvent;
  {#ENDIF ACTIONENABLING}
        {#INITMANUALCODE}
  
        {#INITACTIONSTATE}
        
  {#IFDEF UICONNECTORCREATE}
        FUIConnector = {#UICONNECTORCREATE}();
        // Register Object with the TEnsureKeepAlive Class so that it doesn't get GC'd
        TEnsureKeepAlive.Register(FUIConnector);
  {#ENDIF UICONNECTORCREATE}
  
  {#IFDEF MASTERTABLE OR DETAILTABLE}
        BuildValidationControlsDict();
        SetPrimaryKeyControl();
  {#ENDIF MASTERTABLE OR DETAILTABLE}
      }
  
      #region Show Method overrides
  
      /// <summary>
      /// Override of Form.Show(IWin32Window owner) Method. Caters for singleton Forms.
      /// </summary>
      /// <param name="owner">Any object that implements <see cref="IWin32Window" /> and represents the top-level window that will own this Form. </param>    
      public new void Show(IWin32Window owner)
      {
          Form OpenScreen = TFormsList.GFormsList[this.GetType().FullName];
          bool OpenSelf = true;
  
          if ((OpenScreen != null)
              && (OpenScreen.Modal != true))            
          {
              if (TFormsList.GSingletonForms.Contains(this.GetType().Name)) 
              {
  //                MessageBox.Show("Activating singleton screen of Type '" + this.GetType().FullName + "'.");
                                     
                  OpenSelf = false;
                  this.Visible = false;   // needed as this.Close() would otherwise bring this Form to the foreground and OpenScreen.BringToFront() would not help...
                  this.Close();
                  
                  OpenScreen.BringToFront();
              }            
          }
          
          if (OpenSelf) 
          {
              if (owner != null) 
              {
                  base.Show(owner);    
              }
              else
              {
                  base.Show();
              }            
          }        
      }
  
      /// <summary>
      /// Override of Form.Show() Method. Caters for singleton Forms.
      /// </summary>        
      public new void Show()
      {
          this.Show(null);
      }
  
      #endregion
      
      {#EVENTHANDLERSIMPLEMENTATION}
  {#IFDEF SHOWDETAILS OR GENERATEGETSELECTEDDETAILROW}
  
      /// return the selected row
      public {#DETAILTABLETYPE}Row GetSelectedDetailRow()
      {
          {#GETSELECTEDDETAILROW}
      }
  {#ENDIF SHOWDETAILS OR GENERATEGETSELECTEDDETAILROW}
  
      private void TFrmPetra_Closed(object sender, EventArgs e)
      {
          // TODO? Save Window position
  
  {#IFDEF UICONNECTORCREATE}
          if (FUIConnector != null)
          {
              // UnRegister Object from the TEnsureKeepAlive Class so that the Object can get GC'd on the PetraServer
              TEnsureKeepAlive.UnRegister(FUIConnector);
              FUIConnector = null;
          }
  {#ENDIF UICONNECTORCREATE}
      }
  
      private void SetPrimaryKeyReadOnly(bool AReadOnly)
      {
          {#PRIMARYKEYCONTROLSREADONLY}
      }
  
  {#IFDEF SHOWDATA}
      private void ShowData({#MASTERTABLETYPE}Row ARow)
      {
          {#SHOWDATA}
      }
  {#ENDIF SHOWDATA}
  
  {#IFDEF SHOWDETAILS}
      private void ShowDetails({#DETAILTABLETYPE}Row ARow)
      {
          {#SHOWDETAILS}
      }
  
      private {#DETAILTABLETYPE}Row FPreviouslySelectedDetailRow = null;
  {#ENDIF SHOWDETAILS}
  
  {#IFDEF MASTERTABLE}
  
      /// This method may throw an exception at ARow.EndEdit()
      private void GetDataFromControls({#MASTERTABLETYPE}Row ARow)
      {
  {#IFDEF SAVEDATA}
          if (ARow == null) return;
  
  
gt:         object[] beforeEdit = ARow.ItemArray;