monster commit for zoo flow, prepare migration of cw

This commit is contained in:
Jonathan Jenne
2019-09-12 17:06:14 +02:00
parent 13da64c6ad
commit 6b955569f6
88 changed files with 3001 additions and 130 deletions

View File

@@ -1,10 +1,10 @@
Imports System.ComponentModel
Imports DevExpress.XtraSplashScreen
Imports DevExpress.XtraSplashScreen
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Windows
Imports DigitalData.Modules.ZooFlow
Imports DevExpress.LookAndFeel
Imports ZooFlow.ClassConstants
Imports DigitalData.Products.ClipboardWatcher
Imports DigitalData.Modules.ZooFlow.Params
Partial Public Class frmMain
Private WithEvents FlowForm As frmFlowForm
@@ -16,7 +16,7 @@ Partial Public Class frmMain
InitializeComponent()
End Sub
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
' === Initialization ===
Init = New ClassInit(My.LogConfig, Me)
AddHandler Init.Completed, AddressOf Init_Completed
@@ -27,13 +27,25 @@ Partial Public Class frmMain
End Sub
Private Sub Init_Completed(sender As Object, e As EventArgs)
' Initialization Complete
' === Initialization Complete ===
Loading = False
SplashScreenManager.CloseForm(False)
' Setup Flow Form
' === Setup Timers ===
AddHandler TimerRefreshData.Tick, AddressOf TimerRefreshData_Tick
TimerRefreshData.Enabled = True
' === Setup Flow Form ===
FlowForm = New frmFlowForm(My.Application.ModulesActive)
FlowForm.Show()
' === Load Data ===
RefreshData()
End Sub
Private Sub TimerRefreshData_Tick(sender As Object, e As EventArgs)
RefreshData()
End Sub
Private Sub frmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
@@ -41,7 +53,53 @@ Partial Public Class frmMain
End Sub
Private Sub FlowForm_ClipboardChanged(sender As Object, e As IDataObject) Handles FlowForm.ClipboardChanged
MsgBox("Clipboard Changed!")
If My.Application.ClipboardWatcher.UserProfiles.Rows.Count = 0 Then
Logger.Warn("Clipboard Changed but no profiles configured!")
Exit Sub
End If
Dim oProfileFilter As ClassProfileFilter
Dim oMatchingProfiles As List(Of ProfileData)
Dim oWindow As New Window(My.LogConfig)
Dim oWindowInfo = oWindow.GetWindowInfo()
Dim oFocusedControl As IntPtr = oWindow.FocusedControlinActiveWindow(Handle)
Dim oClipboardContents As String = Clipboard.GetText()
Try
oProfileFilter = New ClassProfileFilter(My.LogConfig, My.Application.ClipboardWatcher.UserProfiles, My.Application.ClipboardWatcher.ProfileProcesses, My.Application.ClipboardWatcher.ProfileWindows, My.Application.ClipboardWatcher.ProfileControls)
oMatchingProfiles = oProfileFilter.Profiles
Logger.Debug("Profiles before filtering: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oProfileFilter.FilterProfilesByClipboardRegex(oMatchingProfiles, oClipboardContents)
Logger.Debug("Profiles after FilterProfilesByClipboardRegex: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oProfileFilter.FilterProfilesByProcess(oMatchingProfiles, oWindowInfo.ProcessName)
Logger.Debug("Profiles after FilterProfilesByProcess: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oProfileFilter.FilterWindowsByWindowTitleRegex(oMatchingProfiles, oWindowInfo.WindowTitle)
Logger.Debug("Profiles after FilterWindowsByWindowTitleRegex: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oProfileFilter.FilterProfilesByFocusedControl(oMatchingProfiles, oClipboardContents, oFocusedControl.ToString)
Logger.Debug("Profiles after FilterProfilesByFocusedControl: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oProfileFilter.ClearNotMatchedProfiles(oMatchingProfiles)
Logger.Debug("Profiles after ClearNotMatchedProfiles: {0}", oMatchingProfiles.Count)
oMatchingProfiles = oMatchingProfiles.ToList()
Catch ex As Exception
MsgBox("Fehler beim Laden der Profile. Möglicherweise liegt ein Konfigurationsfehler vor.", MsgBoxStyle.Critical, Text)
Exit Sub
End Try
If oMatchingProfiles.Count = 0 Then
Logger.Warn("No matching Profiles found")
Exit Sub
End If
Dim oEnvironment As New Environment() With {
.User = My.Application.User,
.Modules = My.Application.Modules
}
Dim oParams As New ClipboardWatcherParams() With {
.MatchingProfiles = oMatchingProfiles
}
Dim oForm As New frmMatch(My.LogConfig, oEnvironment, oParams)
oForm.Show()
End Sub
#Region "Notify Icon Menu"
@@ -71,11 +129,6 @@ Partial Public Class frmMain
End If
End Sub
Private Sub ProgressChanged(sender As Object, Progress As ClassInitLoader.InitProgress)
SplashScreenManager.Default.SendCommand(frmSplash.SplashScreenCommand.SetProgress, Progress.CurrentPercent)
SplashScreenManager.Default.SendCommand(frmSplash.SplashScreenCommand.SetActionName, Progress.CurrentStep.Name)
End Sub
Private Sub ButtonSettings_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles ButtonSettings.ItemClick
frmSettings.ShowDialog()
End Sub
@@ -90,4 +143,27 @@ Partial Public Class frmMain
My.UIConfigManager.Save()
End If
End Sub
Public Sub RefreshData()
Try
Dim oUserId As Integer = My.Application.User.UserId
Dim oSql As String = My.Queries.ClipboardWatcher.VWCW_USER_PROFILE(oUserId)
My.Application.ClipboardWatcher.UserProfiles = My.Database.GetDatatable(oSql)
If My.Application.ClipboardWatcher.UserProfiles.Rows.Count = 0 Then
MsgBox("No profiles configured for this user so far!", MsgBoxStyle.Exclamation)
Else
oSql = My.Queries.ClipboardWatcher.TBCW_PROFILE_PROCESS(oUserId)
My.Application.ClipboardWatcher.ProfileProcesses = My.Database.GetDatatable(oSql)
oSql = My.Queries.ClipboardWatcher.VWCW_PROFILE_REL_WINDOW(oUserId)
My.Application.ClipboardWatcher.ProfileWindows = My.Database.GetDatatable(oSql)
oSql = My.Queries.ClipboardWatcher.VWCW_PROFILE_REL_CONTROL(oUserId)
My.Application.ClipboardWatcher.ProfileControls = My.Database.GetDatatable(oSql)
End If
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
End Class