locked
About de Code Generator of Designer Form. RRS feed

  • Question

  • I'm working with Winforms. Inherits Windows.Forms.Form, create Class that know frmDefault thinking in create a SDK, or framework, based in pattern, all of Applications, know that interfaces Inherits RightNow frmDefault. But i have looking code in de Designer Form with Visual Studio 2008, and all of properties declared in the form inheritable is initialized in Designer Form. Same properties would not have to be in the Designer code. Somebody could help me? As to define some variable or propiedades that will not be controlled for the code in the code inheritable. This variables, some variables store information of security of the application. 

    I'm sorry, i'm not write or speak English better. King Regard's.

    Humberto Queiroz [ humbertoqueiroz@yahoo.com.br ]

    Sunday, September 19, 2010 10:39 PM

Answers

  • Hello,

    I'm  not sure I understood the question but here are some attributes that control design time behavior of properties:

     

    1. Use  BrowsableAttribute to hide property from property browser if it's not suitable for design time editing.
    2. You can control serialization process by applying DesignerSerializationVisiblityAttribute to your property ... use Hidden to stop serialization.
    3. Use DefaultValueAttribute to specify the value which is not to be serialized ... the value should be the same as the initial value of the property when the object gets constructed.
    Looks to me like you should apply both Browsable(false) and [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] to the property you want to Hide from the property grid and not to be serialized to code.

    Best regards,
    Vladimir

     

    Monday, September 20, 2010 12:52 AM
  • Just to add to previous post ... If you need the initial value to be Nothing you can achieve this by implementing TypeConverter for that property:

    Imports System.ComponentModel
    
    Public Class frmDefault
      Private _myAttribute As String = Nothing
    
      <TypeConverter(GetType(MyAttrConverter))> _
      Public Property MyAttribute() As String
        Get
          Return _myAttribute
        End Get
        Set(ByVal value As String)
          _myAttribute = value
        End Set
      End Property
    
    End Class
    
    Public Class MyAttrConverter
      Inherits StringConverter
    
      Public Overrides Function ConvertFrom(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object) As Object
    
        ' we want Nothing instead of String.Empty to be assigned to this property through property grid
        If TypeOf value Is String Then
          If value = String.Empty Then
            Return Nothing
          End If
        End If
    
        Return MyBase.ConvertFrom(context, culture, value)
      End Function
    End Class
    
    

    Now, when you change the value of MyAttribute in the derived form, and then delete it, the property will be assigned the value of Nothing instead of string.Empty and it will not be serialized to code.

     

    Another way to stop it from being serialized to code would be to implement ShoudSerialize[PropertyName] method which would determine if the property should be serialized to code based on it's value... In this case do not apply DefaultValue attribute and you do not need a TypeConverter

      Private Function ShouldSerializeMyAttribute() As Boolean
        If (Me.MyAttribute Is Nothing OrElse Me.MyAttribute = String.Empty) Then
          Return False
        End If
    
        Return True
      End Function
    
    

    Best regards,
    Vladimir

    Tuesday, September 21, 2010 3:19 PM
  • OK, now we have the code for your forms, but I still don't understand the problem. Let's focus on just one property, for instance ChaveAcesso.

    By the way, ChaveAcesso is a property, it will appear in the property grid, _CHAVE_ACESSO is a field and it can not be directly manipulated during the design time.

    Visual Studio, or better yet, forms designer will not initialize any properties. It will serialize current value to code and create InitializeComponent method so that the next time you open the designer or run the application, it can recreate the form. Every public property that is not read-only or write-only, will be serialized to code if the current value is different than the default value, or, when you have form inheritance, it will be serialized if the value is different from the parent's value.

    I need to understand the problem to try to help you ... is it one of these :

    1. Property is visible (and editable) in the property grid and I don't want it to be visible (non editable).

    2. Property not visible (and editable) in the property grid and I would like it to be visible. 

    3. Property gets serialized to code and I don't want it to be serialized if it has default value (of Nothing).

    4. property gets serialized to code and I don't want it to be serialized at all (regardless of the value).

    Or something else ?

    please try to put it as simply as possible.

     

    If someone else has an idea and can help shading some light on the Humberto's problem, please join the conversation ...

     

    P.S. Can't help you with MCPD, I'm not familiar with any MS certification programs.


    Best regards,
    Vladimir

    Tuesday, September 21, 2010 9:46 PM
  • Hi,

     

    1.    Do you mean you want to know why the private controls of parent form are also shown on the child form?

     

    When you call the initialize the child form, it will call parent form constructor and then call the child form constructor.

     

    Open the form code, you will see:

            public Form1()

            {

                InitializeComponent();

            }

     

    All the control are initialized in InitializeComponent() method. This why the child form will get all the parent form controls even this control modifier property is set to private. It doesn't need to add the initializing code in the child form designer code.

     

    If you change the visible property of parent form, the child form control will also changed according to the parent form.

     

    For your third point, you are on the right way. Create a control and with that property with <DefaultValue(false)>. Drag that control on the form can build the project.

    Change that property and rebuild the project. You will see when the property value is False, the designer will not generate code for it.

     

    Hope this helps.

     

    Best regards,

    Ling Wang


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Thursday, September 23, 2010 7:21 AM

All replies

  • Hello,

    I'm  not sure I understood the question but here are some attributes that control design time behavior of properties:

     

    1. Use  BrowsableAttribute to hide property from property browser if it's not suitable for design time editing.
    2. You can control serialization process by applying DesignerSerializationVisiblityAttribute to your property ... use Hidden to stop serialization.
    3. Use DefaultValueAttribute to specify the value which is not to be serialized ... the value should be the same as the initial value of the property when the object gets constructed.
    Looks to me like you should apply both Browsable(false) and [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] to the property you want to Hide from the property grid and not to be serialized to code.

    Best regards,
    Vladimir

     

    Monday, September 20, 2010 12:52 AM
  • Vladimir,

     

    Thanks a lot for the attention!

     

    The question is the code manager for Visual Stúdio, what is the code is Managed or controlled or not. I thought about placing code here, but I am not certain if it would be useful, or clearly. think is i'm have a Class, in this Class, that inherits Windows.Forms.Form, i have am attribute type String.

    Public Class frmDefault

    Private MyAttribute As String = Nothing

    End Class


    I believed that these attributes declared in my class were not controlled for the Designer Code. But he was been deceptive. The attributes are started with values default (In my example, a value is Nothing, but if compare in code, is equals a Empty or a "VALUE" in de code), what I would like that not.

    See in code "DesignerGenerated" look for the properties declared in the Class (Mode Code). All of the attributes suffer initialization with values Default?

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class frmDefault
        Inherits System.Windows.Forms.Form

        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer. 
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> _
        Private Sub InitializeComponent()

         Me.Name = "frmDefault"

         Me.MyAttribute = ""

         End Sub

    End Class

    Tuesday, September 21, 2010 1:00 PM
  • Vladimir,

    I'm Sorry!

     

    In the Childdren Class, the class that inherits the form, this values to by initialized, started. Exists a form to only determine a place, so that these properties are not modified in the class children?

     

    Best Regards,

    Humberto Queiroz.

    Tuesday, September 21, 2010 1:06 PM
  • Hi Humberto,

    I'm sorry but after rereading this couple of times I still don't understand what your problem is ...  maybe you could try to write the question in Portuguese and use Google Language Tools to translate it to English.  

    And please post real code that explains your problem ... try to create a simple test project that reproduces the issue  ... copy - paste from VS, don't improvise on the spot ... the code you posted above just can't be real because MyAttribute is declared as a field (not  a property) and even if it was a property it would've never gotten serialized to code in the frmDefault class ... it would only get serialized in the derived class and only if the value is different from the initial value in the base class.

    EDIT: Now you might be having a problem because your initial value is Nothing ... when you change the value in property grid(e.g. enter some value "aaa"), and then delete it, your property will be assigned with the value "" - string.Empty, not Nothing. So it will be different from the initial value and will be serialized to code. You can stop that by changing the initial value of the property to empty string instead of Nothing.

     

    Best regards,
    Vladimir

    Tuesday, September 21, 2010 2:48 PM
  • Just to add to previous post ... If you need the initial value to be Nothing you can achieve this by implementing TypeConverter for that property:

    Imports System.ComponentModel
    
    Public Class frmDefault
      Private _myAttribute As String = Nothing
    
      <TypeConverter(GetType(MyAttrConverter))> _
      Public Property MyAttribute() As String
        Get
          Return _myAttribute
        End Get
        Set(ByVal value As String)
          _myAttribute = value
        End Set
      End Property
    
    End Class
    
    Public Class MyAttrConverter
      Inherits StringConverter
    
      Public Overrides Function ConvertFrom(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object) As Object
    
        ' we want Nothing instead of String.Empty to be assigned to this property through property grid
        If TypeOf value Is String Then
          If value = String.Empty Then
            Return Nothing
          End If
        End If
    
        Return MyBase.ConvertFrom(context, culture, value)
      End Function
    End Class
    
    

    Now, when you change the value of MyAttribute in the derived form, and then delete it, the property will be assigned the value of Nothing instead of string.Empty and it will not be serialized to code.

     

    Another way to stop it from being serialized to code would be to implement ShoudSerialize[PropertyName] method which would determine if the property should be serialized to code based on it's value... In this case do not apply DefaultValue attribute and you do not need a TypeConverter

      Private Function ShouldSerializeMyAttribute() As Boolean
        If (Me.MyAttribute Is Nothing OrElse Me.MyAttribute = String.Empty) Then
          Return False
        End If
    
        Return True
      End Function
    
    

    Best regards,
    Vladimir

    Tuesday, September 21, 2010 3:19 PM
  • Vladimir,

     

    My English is soo bad. I'm Sorry. Why i post my code? Copy and Paste?

     

    Class Default

    =========

     

    Imports System
    Imports System.Type
    Imports System.Linq
    Imports System.Text
    Imports System.Windows
    Imports System.Windows.Forms
    Imports System.Windows.Forms.Control
    Imports System.Collections.Generic
    Imports System.Reflection
    Imports System.ComponentModel
    Imports System.Xml

    ''' <summary>
    ''' Classe do Tipo Windows.Forms.Form que controla interfaces herdadas por Tipo de Componente e respectiva
    ''' lista de Eventos a serem monitorados.
    ''' </summary>
    Public Class frmDefault
        Inherits Windows.Forms.Form

    #Region "TIPOS E CONSTANTES PADRÃO"

        ''' <summary>
        ''' Flag _FLAG_INICIALIZACAO: Indica se a Interface está incializando!
        ''' </summary>
        Private Shared _FLAG_INIT As Boolean = False
        Public Shared ReadOnly Property emProcessoDeInicializacao()
            Get
                Return (_FLAG_INIT)
            End Get
        End Property

        ''' <summary>
        ''' Flag _FLAG_AUTENTICADO: Indica se a Interface foi autenticada!
        ''' </summary>
        Private _FLAG_AUTENTICADO As Boolean = False
        Protected Property flagAutenticado()
            Get
                Return _FLAG_AUTENTICADO
            End Get
            Set(ByVal value)
                _FLAG_AUTENTICADO = value
            End Set
        End Property

        ''' <summary>
        ''' Caminho para as configurações de conexão da Interface herdada.
        ''' </summary>
        Private _CAMINHO As String
        Property Caminho()
            Get
                Return _CAMINHO
            End Get
            Set(ByVal value)
                _CAMINHO = value
            End Set
        End Property

        ''' <summary>
        ''' Nome do Arquivo para as configurações de conexão da Interface herdada.
        ''' </summary>
        Private _ARQUIVO As String
        Property Arquivo()
            Get
                Return _ARQUIVO
            End Get
            Set(ByVal value)
                _ARQUIVO = value
            End Set
        End Property

        ''' <summary>
        ''' Chave de Acesso da Interface herdada.
        ''' </summary>
        Private _CHAVE_ACESSO As String
        Property ChaveAcesso()
            Get
                Return _CHAVE_ACESSO
            End Get
            Set(ByVal value)
                _CHAVE_ACESSO = value
            End Set
        End Property

    #End Region

     

        Public Sub New()
            MyBase.New()
            InitializeComponent()

        End Sub

        Public Overloads Sub Show()

                MyBase.Show()

        End Sub

        Public Overloads Function ShowDialog() As DialogResult

                Return MyBase.ShowDialog()

        End Function

     

    Class Children

    =========

    Imports System.Windows.Forms

    Public Class frmConfig
        Inherits frmDefault

        Public Sub New()
            MyBase.New()
            ' Esta chamada é necessária para o Windows Form Designer.
            InitializeComponent()

        End Sub

    End Class

     

    The properties _CHAVE_ACESSO, _ARQUIVO and _CAMINHO can't be managed for Visual Stúdio, por example.

     

    And next class or all Class inherits frmConfig, with code equals. One Question: The Types of Attributes and variables can change the behavior of the code? And the method InitializeComponent() can be responsible for initializing the values of properties?

     

    The problem happened on a project whose code is extensive but the question is about what the Visual Studio controls, which parts of the code that is controlled or interfered with Visual Sudio and snippets which could not suffer these same interference.

    Thanks again!

    In course, I'm looking to train for certification MCPD, I believe that better trained, could master the tool in question (Visual Studio). My company will pay the official training here in Brazil. Can you help me also on this issue?

     

    Humberto Queiroz.

    Tuesday, September 21, 2010 3:32 PM
  • OK, now we have the code for your forms, but I still don't understand the problem. Let's focus on just one property, for instance ChaveAcesso.

    By the way, ChaveAcesso is a property, it will appear in the property grid, _CHAVE_ACESSO is a field and it can not be directly manipulated during the design time.

    Visual Studio, or better yet, forms designer will not initialize any properties. It will serialize current value to code and create InitializeComponent method so that the next time you open the designer or run the application, it can recreate the form. Every public property that is not read-only or write-only, will be serialized to code if the current value is different than the default value, or, when you have form inheritance, it will be serialized if the value is different from the parent's value.

    I need to understand the problem to try to help you ... is it one of these :

    1. Property is visible (and editable) in the property grid and I don't want it to be visible (non editable).

    2. Property not visible (and editable) in the property grid and I would like it to be visible. 

    3. Property gets serialized to code and I don't want it to be serialized if it has default value (of Nothing).

    4. property gets serialized to code and I don't want it to be serialized at all (regardless of the value).

    Or something else ?

    please try to put it as simply as possible.

     

    If someone else has an idea and can help shading some light on the Humberto's problem, please join the conversation ...

     

    P.S. Can't help you with MCPD, I'm not familiar with any MS certification programs.


    Best regards,
    Vladimir

    Tuesday, September 21, 2010 9:46 PM
  • Vladimir,

     

    Thanks again for your attention!

    I am studying your first post, your information is being very helpful to me. If you find something, please give suggestions, as in the first post, ok?

    What do you mean when you use the term "grid"? DataGrid?

    Let me think about your questions ...


    I need to understand the problem to try to help you ... is it one of these :

    1. Property is visible (and editable) in the property grid and I don't want it to be visible (non editable).

    2. Property not visible (and editable) in the property grid and I would like it to be visible. 

    3. Property gets serialized to code and I don't want it to be serialized if it has default value (of Nothing).

    4. property gets serialized to code and I don't want it to be serialized at all (regardless of the value).

    Or something else ?

    1. Property is visible (and editable) O.K. But it should be visible only to the class Father and child classes (for protected attributes). In fact, I believe is a problem also object oriented, OOP. The Code of the child class should not show or initialize the attributes of its parent class in the Designer Code. But if we change the visibility attribute of the parent class, the code designer daughter leave the class to initialize an attribute of its parent class?


    And yet on serialization, what happens in the Designer Code? I really liked what you've written about, is already useful. The project I refer to is a bit extensive. In class frmDefault happens the control of child forms. Configuration database, encryption keys are generated and assigned to the attributes of this class father (frmDefault). Classes daughters, in turn these values need to continue with its implementation, because, for example, unauthenticated users by AD (Active Directory) can not implement these interfaces.

    3. Property gets serialized to code and I don't want it to be serialized if it has default value (of Nothing). From what I read, I can change the default startup properties, is it? Get it right? That would solve my current problem. I tried to create an abstract class or an abstract interface, so that the inherited form of this structure. But because it is abstract, a form could not be edited by the Designer Mode (Visualization). I encountered many difficulties when trying to create a design pattern to create an abstraction, an SDK, to re-distribute this solution, saving time in developing new interfaces.

     

    I'll try these suggestions below, you return with the result


    (1) http://msdn.microsoft.com/en-us/library/system.componentmodel.browsableattribute.aspx

    <Browsable(True
    )> _
    Public
     Property
     MyProperty() As
     Integer
    
      Get
    
        ' Insert code here.
    
        Return
     0
      End
     Get
    
      Set
    
        ' Insert code here.
    
      End
     Set
     
    End
     Property
    
    

    (2) http://msdn.microsoft.com/en-us/library/system.componentmodel.defaultvalueattribute.aspx

    Private
     MyVar as
     Boolean
     = False
    
      <DefaultValue(False
    )> _
      Public
     Property
     MyProperty() As
     Boolean
    
        Get
    
          Return
     MyVar
        End
     Get
    
        Set
    
          MyVar = Value
        End
     Set
     
      End
     Property
    
    

     

    About:

    "DesignerSerializationVisibilityAttribute" Class and "DesignerSerializationVisibilityAttribute.Hidden" Field But on these two items mentioned by you, I still do not quite understand. But from what I understand, I can change this behavior Designer Code in order to achieve my goals.

     

    Thank you!


    Best Regards,

    Humberto


    Wednesday, September 22, 2010 11:49 AM
  • Hi,

     

    1.    Do you mean you want to know why the private controls of parent form are also shown on the child form?

     

    When you call the initialize the child form, it will call parent form constructor and then call the child form constructor.

     

    Open the form code, you will see:

            public Form1()

            {

                InitializeComponent();

            }

     

    All the control are initialized in InitializeComponent() method. This why the child form will get all the parent form controls even this control modifier property is set to private. It doesn't need to add the initializing code in the child form designer code.

     

    If you change the visible property of parent form, the child form control will also changed according to the parent form.

     

    For your third point, you are on the right way. Create a control and with that property with <DefaultValue(false)>. Drag that control on the form can build the project.

    Change that property and rebuild the project. You will see when the property value is False, the designer will not generate code for it.

     

    Hope this helps.

     

    Best regards,

    Ling Wang


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Thursday, September 23, 2010 7:21 AM
  • Hi!

     

    Thanks again for your attention!

     

    I believe two things are happening. The first: property is now being configured correctly. But my class frmDefault initializes these values, and as the designer code, also called the parent class, so maybe, the properties are being displayed with predetermined values. I believed that the Designer code not calling the code from the parent. But now it makes sense. As I am inheriting directly from a class "Form", and my child class is initialized by the parent class, it is natural that these same values appear. Though I believe there was a way to not show them in the Designer Code.

     

    In Second: I created a Singleton design pattern to create instances of child classes and be able to manage the memory allocation. Since several of these classes are created and not all are deallocated. This code snippet is foreign to me, excuse me for the amateur, but if someone can help me improve it, thanks!

    The Classes, "frmDefault", "frmLogin", "frmConfig" and "frmAplicacao". FrmDefault and frmLogin is part of SDS, Generated and distributed in the form of DLL. The Classes " frmConfig" and "frmAplicacao" are the application that inherits the previous classes. The class " frmConfig"configures all classes of the new interface, or the new system. All classes that inherit from the SDK, frmConfig have a class that inherits frmDefault consecutively.

     

    One problem is to decrease the amount of code to the development team of new interfaces, because all systems are being migrated to this new architecture. Two problems are the goal of this architecture. One way to capture the users' actions through the Event Clicks, all forms are scanned and clicks all the components are checked. Actions are controlled at all times. Therefore all classes must inherit the same basic structure. The other problem is to ensure that forms are open in memory after closing the system for the Login screen (which was implemented by the DLL).

     

    This code attempts to illustrate my difficulty in modeling, designing the solution in the dotNET platform. I appreciate the help!

     

    Sds,

    Humberto.


    Imports System
    Imports System.Type
    Imports System.Linq
    Imports System.Text
    Imports System.Windows
    Imports System.Windows.Forms
    Imports System.Windows.Forms.Control
    Imports System.Collections.Generic
    Imports System.Reflection
    Imports System.ComponentModel
    Imports System.Xml

    ''' <summary>
    ''' Classe do Tipo Windows.Forms.Form que controla interfaces herdadas por Tipo de Componente e respectiva
    ''' lista de Eventos a serem monitorados.
    ''' </summary>
    Public Class frmDefault
        Inherits Windows.Forms.Form

     

       ''' <summary>
        ''' Formulário Padrão, representa uma Instancia do formulário Padrão, invocado logo após o Login.
        ''' </summary>
        Private _FORMULARIO_PADRAO As frmDefault
        Public Property FormularioPadrao()
            Get
                Return _FORMULARIO_PADRAO
            End Get
            Set(ByVal value)
                _FORMULARIO_PADRAO = value
            End Set
        End Property

        ''' <summary>
        ''' Singleton Padrão para Todos os Forms
        ''' </summary>
        '''
        Private _INSTANCIA_PADRAO As frmDefault
        ''' <summary>
        ''' Tipo do Singleton Padrão para Todos os Forms
        ''' </summary>
        '''
        Private _TIPO_INSTANCIA_PADRAO As Object

        ''' <summary>
        ''' Retorna Singleton Padrão para Todos os Forms
        ''' </summary>
        '''
        Public Function getInstancia() As frmDefault
            If (_INSTANCIA_PADRAO Is Nothing) Or (_INSTANCIA_PADRAO.IsDisposed) Then
                _INSTANCIA_PADRAO = System.Activator.CreateInstance(Me.GetType())
                '_INSTANCIA_PADRAO = System.Activator.CreateInstance(_TIPO_INSTANCIA_PADRAO)
            End If
            Return _INSTANCIA_PADRAO
        End Function

        ''' <summary>
        ''' Configura Singleton Padrão para Todos os Forms
        ''' </summary>
        '''
        Public Sub setInstancia(ByVal pTipo As frmDefault)
            _INSTANCIA_PADRAO = pTipo
        End Sub

       ''' <summary>
        ''' Caminho para as configurações de conexão da Interface herdada.
        ''' </summary>
        Private _CAMINHO As String
        <DefaultValue(False)> _
        Property Caminho()
            Get
                Return _CAMINHO
            End Get
            Set(ByVal value)
                _CAMINHO = value
            End Set
        End Property

        ''' <summary>
        ''' Nome do Arquivo para as configurações de conexão da Interface herdada.
        ''' </summary>
        Private _ARQUIVO As String
        <DefaultValue(False)> _
        Property Arquivo()
            Get
                Return _ARQUIVO
            End Get
            Set(ByVal value)
                _ARQUIVO = value
            End Set
        End Property

        ''' <summary>
        ''' Chave de Acesso da Interface herdada.
        ''' </summary>
        Private _CHAVE_ACESSO As String
        <DefaultValue(False)> _
        Property ChaveAcesso()
            Get
                Return _CHAVE_ACESSO
            End Get
            Set(ByVal value)
                _CHAVE_ACESSO = value
            End Set
        End Property

     

        Public Sub New()
            MyBase.New()
            InitializeComponent()

            ' Singleton
            Me.setInstancia(Me)
            ' Configura Tipo da Instancia Singleton
            _TIPO_INSTANCIA_PADRAO = MyBase.GetType()
        End Sub

     

        Public Function realizaConfiguracoesDeSeguranca() As Boolean
            Try
                ' Chave de Acesso: Cada Interface tem uma chave de acesso única.
                Me.ChaveAcesso = 'DataBase Search Data'
                ' Caminho: Cada Interface tem um caminho único para obter configurações de conexão.
                Me.Caminho = 'DataBase Search Data'
                ' Arquivo: Cada Interface tem um arquivo único para obter configurações de conexão.
                Me.Arquivo = 'DataBase Search Data'
                Return True
            Catch ex As System.IO.FileNotFoundException
                Throw New System.IO.FileNotFoundException("Arquivo de configuração da Interface não encontrado! Mensagem Nativa:" & ex.Message)
                Return False
            End Try
        End Function

     

        Public Overloads Sub Show()
            _FLAG_INIT = False
            Try
                realizaConfiguracoesDeSeguranca()
                MyBase.Show()
            Catch ex As Exception
                MsgBox(ex.Message & " " & "Este Sistema será Finalizado! Favor Entrar em Contato com o Administrador.")
                Me.Close()
            End Try
        End Sub

     

        Public Overloads Function ShowDialog() As DialogResult
            _FLAG_INIT = False
            Try
                realizaConfiguracoesDeSeguranca()
                Return MyBase.ShowDialog()
            Catch ex As Exception
                MsgBox(ex.Message & " " & "Este Sistema será Finalizado! Favor Entrar em Contato com o Administrador.")
                Return DialogResult.Abort
                Me.Close()
            End Try
        End Function

     

    Public Class frmLogin

        Inherits frmDefault

        Public Sub New()

            InitializeComponent()
            ' Configurando o Formulário Padrão.
            ' Determinando o Formulário imediatamente subsequente à tela de login.
            Me.FormularioPadrao = frmAplicacao.getInstancia()

        End Sub

    End Class

     

    Imports System.Windows.Forms

    Public Class frmConfig
        Inherits frmDefault

        Public Sub New()
            MyBase.New()
            ' Esta chamada é necessária para o Windows Form Designer.
            InitializeComponent()
            ' Adicione qualquer inicialização após a chamada InitializeComponent().

        End Sub


    End Class

     

    Public Class frmAplicacao
        Inherits frmConfig

        Public Sub New()
            ' This call is required by the Windows Form Designer.
            InitializeComponent()
            ' Add any initialization after the InitializeComponent() call.
        End Sub

        Private Sub frmAplicacao_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            frmLogin.getInstancia().Show()
            Me.Dispose()
            Me.Close()
        End Sub

    End Class

     

     

    Thursday, September 23, 2010 5:04 PM