From c72f82ebf951644a84b67253c28799cc48c2fe52 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 23 Feb 2022 12:57:09 +0100 Subject: [PATCH] Zooflow: Fix focus issue with search --- GUIs.ZooFlow/Modules/Globix/State.vb | 2 - GUIs.ZooFlow/frmFlowForm.Designer.vb | 6 +- GUIs.ZooFlow/frmFlowForm.resx | 14 +- GUIs.ZooFlow/frmFlowForm.vb | 305 +++++++++++++-------------- 4 files changed, 154 insertions(+), 173 deletions(-) diff --git a/GUIs.ZooFlow/Modules/Globix/State.vb b/GUIs.ZooFlow/Modules/Globix/State.vb index b376950f..7396db7a 100644 --- a/GUIs.ZooFlow/Modules/Globix/State.vb +++ b/GUIs.ZooFlow/Modules/Globix/State.vb @@ -11,14 +11,12 @@ Namespace Globix Public Property CurrentWorkfile As Globix.Models.WorkFile - Public Property CURRENT_IDB_OBJ_ID As Long Public Property INDEXING_ACTIVE As Boolean = False Public Property ABORT_INDEXING As Boolean = False Public Property CURRENT_ISATTACHMENT As Boolean = False Public Property DeleteOriginalFile As Boolean = False Public Property CURRENT_LASTDOCTYPE As String Public Property MULTIINDEXING_ACTIVE As Boolean = False - Public Property CURRENT_PROFILE_LOG_INDEX As String Public Property Folderwatchstarted As Boolean = False Public Property DTEXCLUDE_FILES As DataTable Public Property PATH_FileExclusions As String = Path.Combine(Application.UserAppDataPath(), "FileExclusions.xml") diff --git a/GUIs.ZooFlow/frmFlowForm.Designer.vb b/GUIs.ZooFlow/frmFlowForm.Designer.vb index 6e0d2d8d..86e52daa 100644 --- a/GUIs.ZooFlow/frmFlowForm.Designer.vb +++ b/GUIs.ZooFlow/frmFlowForm.Designer.vb @@ -26,7 +26,7 @@ Partial Class frmFlowForm Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() - Dim SplashScreenManager As DevExpress.XtraSplashScreen.SplashScreenManager = New DevExpress.XtraSplashScreen.SplashScreenManager(Me, GetType(Global.DigitalData.GUIs.ZooFlow.frmSplash), True, True) + Dim SplashScreenManager1 As DevExpress.XtraSplashScreen.SplashScreenManager = New DevExpress.XtraSplashScreen.SplashScreenManager(Me, GetType(Global.DigitalData.GUIs.ZooFlow.frmSplash), True, True) Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmFlowForm)) Me.NotifyIcon = New System.Windows.Forms.NotifyIcon(Me.components) Me.ContextMenuSystray = New System.Windows.Forms.ContextMenuStrip(Me.components) @@ -85,9 +85,9 @@ Partial Class frmFlowForm CType(Me.BarManager1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' - 'SplashScreenManager + 'SplashScreenManager1 ' - SplashScreenManager.ClosingDelay = 500 + SplashScreenManager1.ClosingDelay = 500 ' 'NotifyIcon ' diff --git a/GUIs.ZooFlow/frmFlowForm.resx b/GUIs.ZooFlow/frmFlowForm.resx index ea541636..ad9f2ecb 100644 --- a/GUIs.ZooFlow/frmFlowForm.resx +++ b/GUIs.ZooFlow/frmFlowForm.resx @@ -118,10 +118,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 189, 17 + 196, 17 - 297, 17 + 304, 17 @@ -1957,13 +1957,13 @@ - 461, 17 + 468, 17 - 610, 17 + 617, 17 - 709, 17 + 716, 17 @@ -1993,9 +1993,9 @@ - 858, 17 + 865, 17 - 983, 17 + 990, 17 \ No newline at end of file diff --git a/GUIs.ZooFlow/frmFlowForm.vb b/GUIs.ZooFlow/frmFlowForm.vb index 9684fc2c..9922ddc5 100644 --- a/GUIs.ZooFlow/frmFlowForm.vb +++ b/GUIs.ZooFlow/frmFlowForm.vb @@ -166,7 +166,7 @@ Public Class frmFlowForm Private ClassWindow As Window Private ProfileFilter As ProfileFilter Private ProfileLoader As ClassProfileLoader - Private Property _Environment As Environment + Private Property Environment As Environment ' Runtime Flags Private ApplicationLoading As Boolean = True @@ -188,141 +188,152 @@ Public Class frmFlowForm ' === Initialization === Init = New ClassInit(My.LogConfig, Me) - AddHandler Init.Completed, AddressOf Init_Completed + AddHandler Init.Completed, Async Sub() Await Init_Completed(sender, e) + Init.InitializeApplication() ' === Register Sidebar === RegisterBar(ABEdge.ABE_RIGHT) - End Sub Private Sub frmFlowForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing UnregisterBar() End Sub - Private Sub Init_Completed(sender As Object, e As EventArgs) - Me.Cursor = Cursors.WaitCursor - ' === Initialization Complete === - ApplicationLoading = False - SplashScreenManager.CloseForm(False) - - _Environment = My.Application.GetEnvironment() + Private Async Function Init_Completed(sender As Object, e As EventArgs) As Threading.Tasks.Task + Try + Cursor = Cursors.WaitCursor + ' === Initialization Complete === + ApplicationLoading = False + SplashScreenManager.CloseForm(False) + + ' === Set Form === + OverlayWindowOptions.Default.DisableInput = False + + ' === Initialize Environment === + Logger = My.LogConfig.GetLogger() + Environment = My.Application.GetEnvironment() + ErrorHandler = New BaseErrorHandler(My.LogConfig, Logger, Me) + + ' === Initialize Theming === + If My.Application.Palette = "" Then + UserLookAndFeel.Default.SetSkinStyle(My.Application.Skin) + Else + UserLookAndFeel.Default.SetSkinStyle(My.Application.Skin, My.Application.Palette) + End If - ' === Initialize Error Handler === - Logger = My.LogConfig.GetLogger() - ErrorHandler = New BaseErrorHandler(My.LogConfig, Logger, Me) + ' === Setup Timers === + AddHandler TimerRefreshData.Tick, AddressOf TimerRefreshData_Tick + TimerRefreshData.Enabled = True - If My.Application.Palette = "" Then - UserLookAndFeel.Default.SetSkinStyle(My.Application.Skin) - Else - UserLookAndFeel.Default.SetSkinStyle(My.Application.Skin, My.Application.Palette) - End If + ' === Register As Event Listener === + EventBus.Instance.Register(Me) - ' === Setup Timers === - AddHandler TimerRefreshData.Tick, AddressOf TimerRefreshData_Tick - TimerRefreshData.Enabled = True + ' === Setup Event Handlers === + AddHandler KeyDown, AddressOf frmFlowForm_KeyDown + AddHandler KeyUp, AddressOf frmFlowForm_KeyDown + AddHandler Watcher.ClipboardChanged, AddressOf Watcher_ClipboardChanged - ' === Register As Event Listener === - EventBus.Instance.Register(Me) + 'Dim oSQL = My.Queries.Common.FNIDB_GET_SEARCH_PROFILES(My.Application.User.UserId, My.Application.User.Language) + 'Dim oDatatable As DataTable = My.Database.GetDatatableIDB(oSQL) - ' === Setup Event Handlers === - AddHandler KeyDown, AddressOf frmFlowForm_KeyDown - AddHandler KeyUp, AddressOf frmFlowForm_KeyDown + PictureBoxSearch1.Visible = False + For Each oRow As DataRow In My.Tables.DTIDB_COMMON_SQL.Rows + If oRow.Item("TITLE") = SQLCMD_FLOW_SEARCH_BASE Then + IDBSearchActive = True + PictureBoxSearch1.Visible = True + End If + Next + 'If Not IsNothing(oDatatable) Then + ' If oDatatable.Rows.Count > 0 Then + ' IDBSearchActive = True + ' DTIDB_SEARCHES = oDatatable + ' PictureBoxSearch1.Visible = True + ' End If - AddHandler Watcher.ClipboardChanged, AddressOf Watcher_ClipboardChanged - PictureBoxSearch1.Visible = False + 'End If - 'Dim oSQL = My.Queries.Common.FNIDB_GET_SEARCH_PROFILES(My.Application.User.UserId, My.Application.User.Language) - 'Dim oDatatable As DataTable = My.Database.GetDatatableIDB(oSQL) - For Each oRow As DataRow In My.Tables.DTIDB_COMMON_SQL.Rows - If oRow.Item("TITLE") = SQLCMD_FLOW_SEARCH_BASE Then - IDBSearchActive = True - PictureBoxSearch1.Visible = True + If My.Application.ModulesActive.Contains(MODULE_CLIPBOARDWATCHER) Then + Try + ClassWindow = New Window(My.LogConfig) + HotkeyClass = New Hotkey(Me) + + 'Add Toggle Hotkey + HotkeyClass.AddHotKey(Keys.T, Hotkey.ModfierKey.MOD_CONTROL, HOTKEY_TOGGLE_WATCHER) + + ' Add Trigger Hotkey + + 'TODO: Configure Hotkey + Dim oSearchKey As String = "D" + Dim oFunctionKey As String = "CTRL" + + Dim oConverter As New KeysConverter + Dim oObject As Object = oConverter.ConvertFromString(oSearchKey) + Dim oKeyCode As Keys = oObject + + Select Case oFunctionKey + Case "CTRL" + HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_CONTROL, HOTKEY_TRIGGER_WATCHER) + Case "SHIFT" + HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_SHIFT, HOTKEY_TRIGGER_WATCHER) + Case "ALT" + HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_ALT, HOTKEY_TRIGGER_WATCHER) + Case "WIN" + HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_WIN, HOTKEY_TRIGGER_WATCHER) + End Select + + AddHandler HotkeyClass.HotKeyPressed, AddressOf HotkeyClass_HotKeyPressed + + ProfileLoader = New ClassProfileLoader(My.LogConfig, My.Database) + ProfileLoader.LoadProfiles() + Catch ex As Exception + ShowErrorMessage(ex) + End Try + Else + My.Application.ClipboardWatcher.MonitoringActive = False + Logger.Info("Clipboard Watcher Module is not active. Hotkey Monitoring will be disabled!") End If - Next - 'If Not IsNothing(oDatatable) Then - ' If oDatatable.Rows.Count > 0 Then - ' IDBSearchActive = True - ' DTIDB_SEARCHES = oDatatable - ' PictureBoxSearch1.Visible = True - ' End If - - 'End If - If My.Application.ModulesActive.Contains(MODULE_CLIPBOARDWATCHER) Then - Try - ClassWindow = New Window(My.LogConfig) - HotkeyClass = New Hotkey(Me) + If My.Application.ModulesActive.Contains(MODULE_GLOBAL_INDEXER) Then + FileDropNew = New FileDrop(My.LogConfig, "ZooFlow") + FileHandle = New ClassFilehandle(My.LogConfig) + FolderWatch = New ClassFolderwatcher(My.LogConfig) - 'Add Toggle Hotkey - HotkeyClass.AddHotKey(Keys.T, Hotkey.ModfierKey.MOD_CONTROL, HOTKEY_TOGGLE_WATCHER) - - ' Add Trigger Hotkey - - 'TODO: Configure Hotkey - Dim oSearchKey As String = "D" - Dim oFunctionKey As String = "CTRL" - - Dim oConverter As New KeysConverter - Dim oObject As Object = oConverter.ConvertFromString(oSearchKey) - Dim oKeyCode As Keys = oObject - - Select Case oFunctionKey - Case "CTRL" - HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_CONTROL, HOTKEY_TRIGGER_WATCHER) - Case "SHIFT" - HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_SHIFT, HOTKEY_TRIGGER_WATCHER) - Case "ALT" - HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_ALT, HOTKEY_TRIGGER_WATCHER) - Case "WIN" - HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_WIN, HOTKEY_TRIGGER_WATCHER) - End Select + Dim oFileExclusions As New ClassExclusions() + If oFileExclusions.Load(My.Application.Globix.PATH_FileExclusions) = False Then + If My.Application.User.Language = "de-DE" Then + MsgBox("Die Ausschlusskriterien für Dateien in Folderwatch konnten nicht angelegt werden!", MsgBoxStyle.Information) + Else + MsgBox("File-Exclusions in Folderwatch could not be created!", MsgBoxStyle.Information) + End If - AddHandler HotkeyClass.HotKeyPressed, AddressOf HotkeyClass_HotKeyPressed + End If - ProfileLoader = New ClassProfileLoader(My.LogConfig, My.Database) - ProfileLoader.LoadProfiles() - Catch ex As Exception - ShowErrorMessage(ex) - End Try - Else - My.Application.ClipboardWatcher.MonitoringActive = False - Logger.Info("Clipboard Watcher Module is not active. Hotkey Monitoring will be disabled!") - End If + Init_Folderwatch() + Start_Folderwatch() + GlobixToolStripMenuItem.Visible = True - If My.Application.ModulesActive.Contains(MODULE_GLOBAL_INDEXER) Then - FileDropNew = New FileDrop(My.LogConfig, "ZooFlow") - FileHandle = New ClassFilehandle(My.LogConfig) - FolderWatch = New ClassFolderwatcher(My.LogConfig) + End If - Dim oFileExclusions As New ClassExclusions() - If oFileExclusions.Load(My.Application.Globix.PATH_FileExclusions) = False Then - If My.Application.User.Language = "de-DE" Then - MsgBox("Die Ausschlusskriterien für Dateien in Folderwatch konnten nicht angelegt werden!", MsgBoxStyle.Information) - Else - MsgBox("File-Exclusions in Folderwatch could not be created!", MsgBoxStyle.Information) - End If + If IsNothing(My.Tables.DTIDB_CATALOG_USER) Then + Exit Function End If - Init_Folderwatch() - Start_Folderwatch() - GlobixToolStripMenuItem.Visible = True - - End If + Await ConfigureQuicksearch1(False) + Catch ex As Exception + Logger.Error(ex) - If IsNothing(My.Tables.DTIDB_CATALOG_USER) Then - Exit Sub - End If - Quicksearch1(False) + Finally + Cursor = Cursors.Default - Me.Cursor = Cursors.Default - End Sub - Sub Quicksearch1(Reload As Boolean) + End Try + End Function + Async Function ConfigureQuicksearch1(Reload As Boolean) As Threading.Tasks.Task If Reload Then Dim oSQL = $"SELECT * FROM TBIDB_CATALOG_USER WHERE USR_ID = {My.Application.User.UserId}" - My.Tables.DTIDB_CATALOG_USER = My.Database.GetDatatableIDB(oSQL) + My.Tables.DTIDB_CATALOG_USER = Await My.Database.GetDatatableIDBAsync(oSQL) End If For Each oRow As DataRow In My.Tables.DTIDB_CATALOG_USER.Rows @@ -337,7 +348,7 @@ Public Class frmFlowForm End If End If Next - End Sub + End Function Public Sub RegisterBar(ByVal dockEdge As ABEdge) AppDeskData = New AppDeskBar() AppDeskData.cbSize = Marshal.SizeOf(AppDeskData) @@ -457,10 +468,6 @@ Public Class frmFlowForm End If End Sub - Public Sub OnEvent(Params As Object) - Logger.Debug("OnEvent called!") - End Sub - Private Sub PictureBox1_Click(sender As Object, e As EventArgs) frmSearchNeu.Show() @@ -633,31 +640,12 @@ Public Class frmFlowForm If oDroppedFiles.Count > 0 Then Await Globix_Check_Dropped_Files(oDroppedFiles) End If - - 'If FileDrop.Drop_File(e) = True Then - ' Me.Cursor = Cursors.WaitCursor - ' Await Globix_Check_Dropped_Files() - 'End If End Function Private Async Sub PictureBox1_DragDrop(sender As Object, e As DragEventArgs) Handles PictureBoxDragDrop.DragDrop Await DragDropForm(e) End Sub - 'Private Async Sub TimerCheckDroppedFiles_Tick(sender As Object, e As EventArgs) - ' If Not My.Application.ModulesActive.Contains(ClassConstants.MODULE_GLOBAL_INDEXER) Then - ' Exit Sub - ' End If - - ' Dim oDroppedFiles = FileDropNew.GetFiles(e) - ' If oDroppedFiles.Count > 0 Then - ' Await Globix_Check_Dropped_Files() - ' End If - - ' 'TimerCheckDroppedFiles.Stop() - ' Await Globix_Check_Dropped_Files() - ' Me.Cursor = Cursors.Default - 'End Sub Private Async Function Globix_Check_Dropped_Files(pDroppedFiles As List(Of FileDrop.DroppedFile)) As Threading.Tasks.Task Try Await My.Database.ExecuteNonQueryECMAsync($"DELETE FROM TBGI_FILES_USER WHERE WORKED = 1 AND USER@WORK = '{My.Application.User.UserName}'") @@ -855,8 +843,6 @@ Public Class frmFlowForm End Sub - - Private Sub frmFlowForm_ResizeEnd(sender As Object, e As EventArgs) Handles Me.ResizeEnd My.UIConfig.FlowForm.Location = Location My.UIConfigManager.Save() @@ -938,40 +924,35 @@ Public Class frmFlowForm oState.CurrentClipboardContents = ClipboardContents - 'If oState.MonitoringActive = False Then - ' Dim oMessage As String = "Clipboard Watcher is not active!" - ' Logger.Warn(oMessage) + If oState.MonitoringActive = False Then + Dim oMessage As String = "Clipboard Watcher is not active!" + Logger.Warn(oMessage) - ' Exit Sub - 'End If + End If - 'If oState.UserProfiles Is Nothing Then - ' Dim oMessage As String = "User Profiles are empty!" - ' Logger.Warn(oMessage) + If oState.UserProfiles Is Nothing Then + Dim oMessage As String = "User Profiles are empty!" + Logger.Warn(oMessage) - ' Exit Sub - 'End If + End If - 'If oState.ProfileProcesses Is Nothing OrElse oState.ProfileProcesses.Rows.Count = 0 Then - ' Dim oMessage As String = "Profile Processes are empty!" - ' Logger.Warn(oMessage) + If oState.ProfileProcesses Is Nothing OrElse oState.ProfileProcesses.Rows.Count = 0 Then + Dim oMessage As String = "Profile Processes are empty!" + Logger.Warn(oMessage) - ' Exit Sub - 'End If + End If - 'If oState.ProfileWindows Is Nothing OrElse oState.ProfileWindows.Rows.Count = 0 Then - ' Dim oMessage As String = "Profile Windows are empty!" - ' Logger.Warn(oMessage) + If oState.ProfileWindows Is Nothing OrElse oState.ProfileWindows.Rows.Count = 0 Then + Dim oMessage As String = "Profile Windows are empty!" + Logger.Warn(oMessage) - ' Exit Sub - 'End If + End If - 'If oState.ProfileControls Is Nothing OrElse oState.ProfileControls.Rows.Count = 0 Then - ' Dim oMessage As String = "Profile Processes are empty!" - ' Logger.Warn(oMessage) + If oState.ProfileControls Is Nothing OrElse oState.ProfileControls.Rows.Count = 0 Then + Dim oMessage As String = "Profile Processes are empty!" + Logger.Warn(oMessage) - ' Exit Sub - 'End If + End If Dim oWindowInfo = ClassWindow.GetWindowInfo() @@ -1089,7 +1070,7 @@ Public Class frmFlowForm Private Async Sub ProfileResultForm_NeedsRefresh(sender As Object, e As Integer) Dim oThisForm As IResultForm = sender Dim oState = My.Application.ClipboardWatcher - Dim oProfileSearch As New ProfileSearches(My.LogConfig, _Environment, oState.CurrentClipboardContents) + Dim oProfileSearch As New ProfileSearches(My.LogConfig, Environment, oState.CurrentClipboardContents) If TypeOf sender Is frmDocumentResultList Then Dim oProfileId = e @@ -1110,9 +1091,9 @@ Public Class frmFlowForm End Sub - Private Sub BasisKonfigurationToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BasisKonfigurationToolStripMenuItem.Click + Private Async Sub BasisKonfigurationToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BasisKonfigurationToolStripMenuItem.Click frmConfigBasic.ShowDialog() - Quicksearch1(True) + Await ConfigureQuicksearch1(True) End Sub Private Sub ShowErrorMessage(pEx As Exception) @@ -1154,8 +1135,10 @@ Public Class frmFlowForm .Title = GetResultWindowString(pSearchText), .Datatable = oDTDocResult }) - Dim oForm As New frmDocumentResultList(My.LogConfig, _Environment, oParams) + Dim oForm As New frmDocumentResultList(My.LogConfig, Environment, oParams) oForm.Show() + oForm.BringToFront() + oForm.Focus() Else Dim oMessage As String @@ -1232,9 +1215,9 @@ Public Class frmFlowForm End If End Sub - Private Sub BarButtonItem8_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem8.ItemClick + Private Async Sub BarButtonItem8_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem8.ItemClick frmConfigBasic.ShowDialog() - Quicksearch1(True) + Await ConfigureQuicksearch1(True) End Sub End Class