Imports DevExpress.XtraNavBar
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraBars
Imports System.ComponentModel
Imports System.Threading
Imports System.Globalization

Public Class frmMain

    Public Shared TIMER_SCAN As New System.Windows.Forms.Timer

    Public Shared Sub RUN_TIMER()
        Try
            If TIMER_SCAN.Enabled = False Then
                TIMER_SCAN.Interval = 10000
                TIMER_SCAN.Enabled = True
                AddHandler TIMER_SCAN.Tick, AddressOf Scan_TickHandler
            End If
        Catch ex As Exception
            MsgBox("Unexpected Error in RUN_TIMER:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try

    End Sub
    Private Shared Sub Scan_TickHandler(sender As Object, e As EventArgs)
        Try
            Dim sql1 As String = String.Format("select * from TBPMO_FILES_USER where HANDLE_TYPE = 'SCAN' and WORKED = 0 AND UPPER(USER_WORK) = '{0}'", Environment.UserName)
            Dim DT As DataTable = ClassDatabase.Return_Datatable(sql1, "Load ScanFiles")
            If Not IsNothing(DT) Then
                CURRENT_SCAN_TABLE = DT
                If DT.Rows.Count > 0 Then
                    Dim open As Boolean = False
                    For Each form In My.Application.OpenForms
                        If (form.name = frmScanFiles.Name) Then
                            'form is loaded so can do work 
                            'if you need to check whether it is actually visible
                            If form.Visible Then
                                open = True
                                'do work when visible
                                If My.Settings.User_InBoxScan_NotinFront = False Then
                                    frmScanFiles.BringToFront()
                                End If
                            Else

                            End If
                        End If
                    Next
                    If open = False Then
                        Dim frm As New frmScanFiles
                        frm = frmScanFiles.Instance()
                        frm.Show()
                    End If
                End If
                If DT.Rows.Count = 0 Then
                    frmScanFiles.Close()
                End If
            End If
        Catch ex As Exception
            MsgBox("Unexpected Error in Scan_TickHandler:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
            TIMER_SCAN.Enabled = False
        End Try
    End Sub
    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
        Try
            ' Referenz zu frmMain speichern
            MAIN_FORM = Me

            ' Form Titel setzen
            ClassWindowLocation.LoadFormLocationSize(Me, 1, CURRENT_SCREEN_ID, "frmMain")
            Dim i = My.Application.UICulture.ToString()

            'Dim splash As New frmSplash()
            'splash.ShowDialog()

            ' MainForm Hintergrund laden
            SetBackgroundImage()

            Me.Text = Application.ProductName
            LabelVersion.Caption = String.Format("Version {0}", My.Application.Info.Version.ToString)
            LabelUser.Caption = Environment.UserName
            LabelMachine.Caption = My.Computer.Name

            Load_Connection_Dep_Data()

            'Wenn Argumente übergeben wurden, wird Formular geladen und zu record gesprungen
            ClassJumpRecord.ParseArgs()

        Catch ex As Exception
            MsgBox("Error in Load Form:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    Sub Load_Connection_Dep_Data()
        SetBackground()
        If ERROR_INIT = "NONE" Then
            If USER_IS_ADMIN = True Then
                pageAdmin.Visible = True
            End If

            LabelLoggedIn.Caption = "Anzahl Angemeldete User: " & USERS_LOGGED_IN.ToString()

            'LoadMenuItems()
            LoadMenuItems2()
            LoadQuickStartItems()
        ElseIf ERROR_INIT = "DATABASE" Then
            Load_ConfigBasic()
        End If
        Load_TasksforUser()
    End Sub
    Sub Load_TasksforUser()
        Try
            VWPMO_WF_USER_ACTIVETableAdapter.Connection.ConnectionString = MyConnectionString
            Me.VWPMO_WF_USER_ACTIVETableAdapter.FillByUser(Me.DD_DMSDataSet.VWPMO_WF_USER_ACTIVE, Environment.UserName)
            CURRENT_TASKS_GENERAL = Me.DD_DMSDataSet.VWPMO_WF_USER_ACTIVE
        Catch ex As Exception
            MsgBox("Error in Load Tasks:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        Try
            Dim sql = "UPDATE TBDD_USER SET LOGGED_IN = @LogInOut, LOGGED_WHERE = '@ANGEMELDETWO' WHERE (LOWER(USERNAME) = LOWER('@user'))"
            sql = sql.Replace("@LogInOut", 0)
            sql = sql.Replace("@ANGEMELDETWO", "''")
            sql = sql.Replace("@user", Environment.UserName)
            ClassDatabase.Execute_non_Query(sql)
            sql = "DELETE FROM TBDD_USER_MODULE_LOG_IN WHERE USER_ID = " & USER_GUID & " AND MODULE = 'RECORD_ORGANIZER'"
            ClassDatabase.Execute_non_Query(sql)
            ClassWindowLocation.SaveFormLocationSize(Me, 1, CURRENT_SCREEN_ID, "frmMain")
            ToolStripManager.SaveSettings(Me)

            My.Settings.Save()

        Catch ex As Exception

        End Try
        'TempDateien löschen
        Try
            For Each _file In TEMP_FILES
                System.IO.File.Delete(_file)
            Next
        Catch ex As Exception

        End Try
    End Sub

    Private Shared Function LoadNoImage() As Bitmap
        Return Nothing
    End Function

    Private Shared Function LoadImage(path As Object)
        If Not IsDBNull(path) Then
            Dim filepath As String = DirectCast(path, String)
            filepath = CType(path, String)
            If System.IO.File.Exists(path) Then
                Return New Bitmap(filepath)
            Else
                Return LoadNoImage()
            End If
        Else
            Return LoadNoImage()
        End If
    End Function

    Public Sub LoadMenuItems2()
        Try
            Dim SQL2 As String = String.Format("SELECT GUID, dbo.FNPMO_GETOBJECTCAPTION('{0}', 'CONSTR_MENUE' + CONVERT(VARCHAR(5), GUID), {1}) AS FORM_TITLE, SEQUENCE_MENU, ADDED_WHO, ADDED_WHEN, CHANGED_WHO," & _
            "CHANGED_WHEN, MENU_IMG, SHORT_TITLE, LANGUAGE, " & _
            "'CONSTR_MENUE' + CONVERT(VARCHAR(5), GUID) as OBECTNAME FROM TBPMO_FORM_CONSTRUCTOR where GUID in (SELECT CONSTRUCT_ID FROM TBPMO_CONSTRUCTOR_USER WHERE HOME_MENUE = 0 AND USER_ID = {2}) ORDER BY SEQUENCE_MENU", USER_LANGUAGE, CURRENT_SCREEN_ID, USER_GUID)
            Dim dt As DataTable = ClassDatabase.Return_Datatable(SQL2)

            If dt.Rows.Count <> 0 Then

                For Each row As DataRow In dt.Rows
                    Dim image As Bitmap = Nothing

                    If IsDBNull(row.Item("MENU_IMG")) Then
                        image = My.Resources.ResourceManager.GetObject("changechartlegendalignment_32x32")
                    Else
                        Dim bimg() As Byte = row.Item("MENU_IMG")
                        Dim bitmap As Bitmap = ByteArrayToBitmap(bimg)
                        image = bitmap
                    End If

                    Dim title = row.Item("FORM_TITLE")
                    If title = "CAPTION (OBJ) NOT TRANSLATED" Then
                        Dim objectname = row.Item("OBECTNAME")
                        Dim objectname_temp = String.Format("Object {0} not translated", objectname)
                        Dim ins = String.Format("INSERT INTO TBPMO_LANGUAGE_OBJECT (LANGUAGE_TYPE,SCREEN_ID,PMO_OBJECT_NAME,CAPTION) VALUES " & _
                                                "('{0}',{1},'{2}', '{3}')", USER_LANGUAGE, CURRENT_SCREEN_ID, objectname, objectname_temp)
                        If ClassDatabase.Execute_non_Query(ins) = True Then
                            title = objectname_temp
                        End If
                    End If


                    Dim index As Integer = row.Item("SEQUENCE_MENU")
                    Dim tag As Integer = row.Item("GUID")
                    Dim item As New BarButtonItem(ribbonMain.Manager, title)
                    item.RibbonStyle = RibbonItemStyles.Large
                    item.Caption = title
                    item.Tag = tag
                    item.Glyph = image
                    item.LargeGlyph = image

                    AddHandler item.ItemClick, AddressOf ToolbarButtonItemClick
                    groupQuickAccessForm2.ItemLinks.Add(item)

                Next

            End If
        Catch ex As Exception
            MsgBox("Unexpected Error in Load QuickStart-Items:" & vbNewLine & ex.Message)
        End Try

        'Dim SQL As String = "SELECT * FROM TBPMO_MENU_FORM"
        'Dim dtRootMenu As DataTable = ClassDatabase.Return_Datatable(SQL)
        'ss()
        'pageForms.Groups.Clear()

        'If dtRootMenu.Rows.Count <> 0 Then

        '    For Each row As DataRow In dtRootMenu.Rows

        '        Dim MenuID As Integer = row.Item("GUID")
        '        Dim groupTitle As String = row.Item("MENU_ENTRY")
        '        Dim group As New RibbonPageGroup(groupTitle)
        '        Dim dtSubMenu As DataTable
        '        Dim image As Bitmap = LoadImage(row.Item("ICON_PATH"))

        '        group.Glyph = image
        '        group.AllowTextClipping = False

        '        SQL = "SELECT * FROM TBPMO_MENU_FORM_ENTRIES WHERE MENU_FORM_ID = " & MenuID
        '        dtSubMenu = ClassDatabase.Return_Datatable(SQL)

        '        If dtSubMenu.Rows.Count <> 0 Then

        '            For Each subRow As DataRow In dtSubMenu.Rows

        '                Dim itemTitle As String = subRow.Item("MENU_ENTRY")
        '                Dim tag As String = subRow.Item("FORM_ID")
        '                Dim item As New BarButtonItem(ribbonMain.Manager, itemTitle)

        '                Dim subimage As Bitmap = LoadImage(subRow.Item("ICON_PATH"))

        '                item.RibbonStyle = RibbonItemStyles.SmallWithText
        '                item.Tag = tag
        '                item.Glyph = subimage

        '                AddHandler item.ItemClick, AddressOf BarButtonItemClick

        '                group.ItemLinks.Add(item)

        '            Next

        '            pageForms.Groups.Add(group)
        '        End If

        '    Next

        'End If
    End Sub
    Public Sub LoadQuickStartItems()
        Try
            Dim SQL2 As String = String.Format("SELECT GUID, dbo.FNPMO_GETOBJECTCAPTION('{0}', 'CONSTR_MENUE' + CONVERT(VARCHAR(5), GUID), {1}) AS FORM_TITLE, SEQUENCE_MENU, ADDED_WHO, ADDED_WHEN, CHANGED_WHO," & _
            "CHANGED_WHEN, MENU_IMG, SHORT_TITLE, LANGUAGE, " & _
            "'CONSTR_MENUE' + CONVERT(VARCHAR(5), GUID) as OBECTNAME FROM TBPMO_FORM_CONSTRUCTOR where GUID in (SELECT CONSTRUCT_ID FROM TBPMO_CONSTRUCTOR_USER WHERE HOME_MENUE = 1 AND USER_ID = {2}) ORDER BY SEQUENCE_MENU", USER_LANGUAGE, CURRENT_SCREEN_ID, USER_GUID)
            Dim dt As DataTable = ClassDatabase.Return_Datatable(SQL2)
            Dim image2 As Bitmap = LoadNoImage()

            Try
                If Not IsNothing(groupQuickAccessForm) Then
                    Do While 0 < groupQuickAccessForm.ItemLinks.Count
                        groupQuickAccessForm.ItemLinks.Remove(groupQuickAccessForm.ItemLinks(0))
                    Loop
                End If
            Catch ex As Exception

            End Try



            If dt.Rows.Count <> 0 Then

                For Each row As DataRow In dt.Rows
                    If Not IsDBNull(row.Item("MENU_IMG")) Then
                        Dim bimg() As Byte = row.Item("MENU_IMG")
                        Dim bitmap As Bitmap = ByteArrayToBitmap(bimg)
                        image2 = bitmap
                    End If
                    Dim title = row.Item("FORM_TITLE")
                    If title = "CAPTION (OBJ) NOT TRANSLATED" Then
                        Dim objectname = row.Item("OBECTNAME")
                        Dim objectname_temp = String.Format("Object {0} not translated", objectname)
                        Dim ins = String.Format("INSERT INTO TBPMO_LANGUAGE_OBJECT (LANGUAGE_TYPE,SCREEN_ID,PMO_OBJECT_NAME,CAPTION) VALUES " & _
                                                "('{0}',{1},'{2}', '{3}')", USER_LANGUAGE, CURRENT_SCREEN_ID, objectname, objectname_temp)
                        If ClassDatabase.Execute_non_Query(ins) = True Then
                            title = objectname_temp
                        End If
                    End If


                    Dim index As Integer = row.Item("SEQUENCE_MENU")
                    Dim tag As Integer = row.Item("GUID")
                    Dim item As New BarButtonItem(ribbonMain.Manager, title)
                    item.RibbonStyle = RibbonItemStyles.Large
                    item.Caption = title
                    item.Tag = tag
                    item.Glyph = image2

                    AddHandler item.ItemClick, AddressOf ToolbarButtonItemClick
                    groupQuickAccessForm.ItemLinks.Add(item)

                Next

            End If
        Catch ex As Exception
            MsgBox("Unexpected Error in Load QuickStart-Items:" & vbNewLine & ex.Message)
        End Try

    End Sub


    Private Sub BarButtonItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs)
        Dim formId As Integer = Integer.Parse(e.Item.Tag)

        Cursor = Cursors.WaitCursor
        OpenFormInputFor(formId, 1)
        Cursor = Cursors.Default
    End Sub

    Private Sub ToolbarButtonItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs)
        Dim formId As Integer = Integer.Parse(e.Item.Tag)

        Cursor = Cursors.WaitCursor
        OpenFormConstructor(formId)
        Cursor = Cursors.Default
    End Sub

    Private Sub NavbarItem_Click(sender As Object, e As NavBarLinkEventArgs)
        Dim formID As Integer = Integer.Parse(e.Link.Item.Tag)

        Cursor = Cursors.WaitCursor
        OpenFormConstructor(formID)
        Cursor = Cursors.Default
    End Sub

    Private Sub MenuItemClick(sender As Object, e As EventArgs)
        Dim item As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem)
        Dim formId As Integer = Integer.Parse(item.Tag)

        Cursor = Cursors.WaitCursor
        OpenFormInputFor(formId, 1)
        Cursor = Cursors.Default
    End Sub
    Private Sub MenuItem2Click(sender As Object, e As EventArgs)
        Dim item As ToolStripMenuItem = DirectCast(sender, ToolStripMenuItem)
        Dim formId As Integer = Integer.Parse(item.Tag)
        Cursor = Cursors.WaitCursor
        OpenFormConstructor(formId)
        Cursor = Cursors.Default
    End Sub

    Private Shared Sub QuickAccessClick(sender As Object, e As EventArgs)
        Dim btn As ToolStripButton = CType(sender, ToolStripButton)
        Dim formId As Integer
        formId = Integer.Parse(sender.tag)
        OpenFormConstructor(formId)
    End Sub

    Private Sub SetBackground()
        Dim ctrl As Control
        Dim ctrlMDI As MdiClient

        For Each ctrl In Me.Controls
            Try
                ctrlMDI = CType(ctrl, MdiClient)
                ctrlMDI.BackColor = Me.BackColor
            Catch ex As Exception

            End Try
        Next
    End Sub

    Private Sub SetBackgroundImage()
        Dim SQL As String = "SELECT BACKGROUND_IMAGE FROM TBDD_MODULES WHERE NAME = 'Record-Organizer'"
        Dim bimage() As Byte = ClassDatabase.Execute_Scalar(SQL)

        If Not IsDBNull(bimage) Then

            Dim image As Bitmap = ByteArrayToBitmap(bimage)
            Me.BackgroundImage = image
            Me.BackgroundImageLayout = ImageLayout.Center

        End If
    End Sub

    Sub Refresh_TaskReminder()
        Load_TasksforUser()
        Try
            If DD_DMSDataSet.VWPMO_WF_USER_ACTIVE.Rows.Count > 0 Then
                NotifyIcon.Visible = True
                If USER_LANGUAGE = "de-DE" Then
                    NotifyIcon.ShowBalloonTip(50000, "ADDI-Unerledigte Tasks", "Sie haben unerledigte Tasks in Ihrem Verantwortungsbereich." & vbNewLine & "Bitte überprüfen Sie Ihre Workflow-Tasks", ToolTipIcon.Info)
                Else
                    NotifyIcon.ShowBalloonTip(50000, "ADDI-Pending Tasks", "You have pending tasks in Your authority." & vbNewLine & "Please check Your Tasks", ToolTipIcon.Info)
                End If

            End If
        Catch ex As Exception
            MsgBox("Error in Refresh_TaskReminder:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub
    Private Sub EbenenKonfiguratorToolStripMenuItem_Click(sender As Object, e As EventArgs)
        Cursor = Cursors.WaitCursor
        OpenFormOverview()
        Cursor = Cursors.Default
    End Sub
    Private Sub KalenderToolStripMenuItem_Click(sender As Object, e As EventArgs)
        Cursor = Cursors.WaitCursor
        OpenFormCalendar()
        Cursor = Cursors.Default
    End Sub

    Private Sub BeendenToolStripMenuItem_Click(sender As Object, e As EventArgs)
        Me.Close()
    End Sub

    Private Sub FormateProduktionenToolStripMenuItem_Click(sender As Object, e As EventArgs)
        OpenFormConstructor(1)
    End Sub

    Private Sub WorkflowTaskmanagementToolStripMenuItem_Click(sender As Object, e As EventArgs)
        OpenTaskmanagement()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Refresh_TaskReminder()
    End Sub

    Private Sub frmMain_Resize(sender As Object, e As EventArgs) Handles Me.Resize
        ' Repaint Form on Resize End
        Me.Invalidate(True)
        Me.Update()
    End Sub

    Private Sub frmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Refresh_TaskReminder()
        Timer1.Start()
        RUN_TIMER()
        If Sett_ConstructorStart <> 0 Then
            Cursor = Cursors.WaitCursor
            OpenFormConstructor(Sett_ConstructorStart)
            Cursor = Cursors.Default
        End If
        'Lizenz abgellaufen, überprüfen ob User Admin ist
        If LICENSE_COUNT < USERS_LOGGED_IN Then
            If USER_IS_ADMIN = True Then
                ClassLogger.Add(">> User is Admin - Timer will be started", False)
                'If USER_LANGUAGE = "de-DE" Then
                MsgBox("Sie haben nun 3 Minuten Zeit eine neue Lizenz zu vergeben!", MsgBoxStyle.Information)
                'Else
                '    MsgBox("You now got 3 minutes to update the license!", MsgBoxStyle.Information)
                'End If

                'Timer starten
                If TimerClose3Minutes.Enabled = False Then
                    TimerClose3Minutes.Start()
                End If
            End If
        End If
        'If DOCTYPE_COUNT_ACTUAL > LICENSE_DOCTYPE_COUNT Then
        '    If CURRENT_USER_IS_ADMIN = True Then
        '        ClassLogger.Add(">> User is Admin - Timer will be started", False)
        '        If USER_LANGUAGE = "de-DE" Then
        '            MsgBox("Sie haben nun 3 Minuten Zeit eine neue Lizenz zu vergeben!", MsgBoxStyle.Information)
        '        Else
        '            MsgBox("You now got 3 minutes to update the license!", MsgBoxStyle.Information)
        '        End If

        '        'Timer starten
        '        If TimerClose3Minutes.Enabled = False Then
        '            TimerClose3Minutes.Start()
        '        End If
        '    End If
        'End If


    End Sub
    Private Sub DokumentartkonfigurationToolStripMenuItem_Click(sender As Object, e As EventArgs)
        OpenDokumentartt()
    End Sub

    Private Sub MenuKonfigurationToolStripMenuItem_Click(sender As Object, e As EventArgs)
        OpenMenuDesigner()
    End Sub

    Private Sub UserKonfigurationToolStripMenuItem_Click(sender As Object, e As EventArgs)
        OpenUserKonfig()
    End Sub
    Private Sub ImageManagerToolStripMenuItem_Click(sender As Object, e As EventArgs)
        OpenImageManager()
    End Sub

    Private Sub tsQuickMenue_LocationChanged(sender As Object, e As EventArgs)
        'Console.WriteLine("locChanged" & tsQuickMenue.Location.ToString)
        'If tsQuickMenue.Location.ToString <> "{X=0,Y=0}" Then
        '    SaveMySettingsValue("tsQuickMenueLocation", tsQuickMenue.Location.ToString)
        'End If


    End Sub
    Private Sub GrundeinstellungenWindreamToolStripMenuItem_Click(sender As Object, e As EventArgs)
        OpenObjecttypeConfig()
    End Sub

    Private Sub MenuStrip1_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs)

    End Sub

    Private Sub GrundeinstellungenToolStripMenuItem_Click(sender As Object, e As EventArgs)
        frmConfiguration_Basic.ShowDialog()
    End Sub

    Private Sub BarButtonItem1_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem1.ItemClick
        OpenFormCalendar()
    End Sub

    Private Sub itemInfo_ItemClick(sender As Object, e As ItemClickEventArgs) Handles itemInfo.ItemClick
        frmAbout.ShowDialog()
    End Sub

    Private Sub itemExit_ItemClick(sender As Object, e As ItemClickEventArgs) Handles itemExit.ItemClick
        Me.Close()
    End Sub

    Private Sub itemSettings_ItemClick(sender As Object, e As ItemClickEventArgs) Handles itemSettings.ItemClick
        Load_ConfigBasic()
    End Sub
    Sub Load_ConfigBasic()
        frmConfig_Basic.ShowDialog()
        If LANGUAGE_CHANGED = True Then
            MsgBox("Application will restart now!", MsgBoxStyle.Information)
            Application.Restart()
        End If
        If CONNECTION_CHANGED = True Then
            Load_Connection_Dep_Data()
        End If
    End Sub
    Private Sub BarButtonItem3_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem3.ItemClick
        Cursor = Cursors.WaitCursor
        OpenFormOverview()
        Cursor = Cursors.Default
    End Sub

    Private Sub BarButtonItem4_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem4.ItemClick
        OpenTaskmanagement()
    End Sub

    Private Sub BarButtonItem5_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem5.ItemClick
        OpenUserKonfig()
    End Sub

    Private Sub BarButtonItem6_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem6.ItemClick
        OpenMenuDesigner()
    End Sub

    Private Sub BarButtonItem7_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem7.ItemClick
        OpenImageManager()
    End Sub

    Private Sub BarButtonItem8_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem8.ItemClick
        Close_Maximized_Forms()
        OpenDokumentartt()
    End Sub

    Private Sub BarButtonItem9_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem9.ItemClick
        Close_Maximized_Forms()
        OpenObjecttypeConfig()
    End Sub

    Private Sub BarButtonItem2_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem2.ItemClick
        frmConfiguration_Basic.ShowDialog()
    End Sub

    Private Sub BarButtonItem10_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem10.ItemClick
        Load_ConfigBasic()
    End Sub

    Private Sub BarButtonItem12_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem12.ItemClick
        OpenWiedervorlage()
    End Sub

    Private Sub BarButtonItem13_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem13.ItemClick
        OpenLogRecord()
    End Sub

    Private Sub BarButtonItem14_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem14.ItemClick
        Dim frm As New frmConnections
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub BarButtonItem16_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem16.ItemClick
        Close_Maximized_Forms()
        Dim frm As New frmConstructorDesigner
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Private Sub BarButtonItem17_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem17.ItemClick
        OpenTemplatemanagement()
    End Sub

    Private Sub TimerClose3Minutes_Tick(sender As Object, e As EventArgs) Handles TimerClose3Minutes.Tick
        If LICENSE_EXPIRED = True Or LICENSE_COUNT < USERS_LOGGED_IN Then
            'If USER_LANGUAGE = "de-DE" Then
            '    MsgBox("Global Indexer wird nun geschlossen, weil keine neue Lizenzdaten eingegeben wurden!", MsgBoxStyle.Information)
            'Else
            MsgBox("Record Organizer will now be closed, cause no new license was updated!", MsgBoxStyle.Information)
            'End If
            Me.Close()
        Else
            TimerClose3Minutes.Stop()
        End If
    End Sub

    Private Sub frmMain_KeyUp(sender As Object, e As KeyEventArgs) Handles MyBase.KeyUp
        Select Case e.KeyCode
            Case Keys.F12
                Try
                    frmLicense.ShowDialog()
                Catch ex As Exception

                End Try
        End Select
    End Sub

    Private Sub BarButtonItem18_ItemClick(sender As Object, e As ItemClickEventArgs) Handles BarButtonItem18.ItemClick
        Close_Maximized_Forms()
        Dim frm As New frmLanguage_Translator
        frm.MdiParent = Me
        frm.Show()
    End Sub

    Public Sub New()
        Dim splash As New frmSplash()
        splash.ShowDialog()
        Dim cultureInfo As System.Globalization.CultureInfo
        cultureInfo = New System.Globalization.CultureInfo(USER_LANGUAGE)

        Thread.CurrentThread.CurrentCulture = cultureInfo
        Thread.CurrentThread.CurrentUICulture = cultureInfo
        cultureInfo.DefaultThreadCurrentCulture = cultureInfo
        cultureInfo.DefaultThreadCurrentUICulture = cultureInfo
        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.

    End Sub

    Private Sub NotifyIcon_Click(sender As Object, e As EventArgs) Handles NotifyIcon.Click

    End Sub

    Private Sub NotifyIcon_BalloonTipClicked(sender As Object, e As EventArgs) Handles NotifyIcon.BalloonTipClicked
        OpenFormCockpit()
    End Sub
End Class
