Common: Translate DocumentResultList

This commit is contained in:
Jonathan Jenne
2021-06-07 15:08:26 +02:00
parent 84b16fb730
commit e36013d730
5 changed files with 1704 additions and 534 deletions

View File

@@ -54,6 +54,7 @@ Public Class frmDocumentResultList
Private WithEvents _FileOpenTimer As New Timer
Private _OpenDocuments As New DocumentResultCache(50000000)
Private _CurrentDocument As DocumentResultInfo = Nothing
Private _Language As String
Private Property OperationMode As IResultForm.Mode Implements IResultForm.OperationMode
@@ -81,8 +82,7 @@ Public Class frmDocumentResultList
_Params = Params
_ResultLists = Params.Results
'_FileOpenTimer.Interval = FILE_OPEN_TIMER_INTERVAL
'_FileOpenTimer.Start()
_Language = Utils.NotNull(_Environment.User.Language, State.UserState.LANG_EN_US)
End Sub
Private Sub frmDocumentResultList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@@ -192,9 +192,6 @@ Public Class frmDocumentResultList
DocumentViewer1.SetViewOnly(False)
RibbonPageGroup_Export.Visible = True
End If
' TODO: Create checksum after closing, compare and take action
'_HashOriginalFile = _Filesystem.GetChecksum(oDocumentInfo.FullPath)
End If
Catch ex As Exception
_Logger.Error(ex)
@@ -325,56 +322,6 @@ Public Class frmDocumentResultList
End Try
End Function
'Private Function LoadFile_AsByteArray(DocumentInfo As DocumentResultInfo)
' Try
' Dim oLoadedInfo As DocumentResultInfo = Nothing
' Dim oFileContents As Byte()
' Dim oFullPath As String = DocumentInfo.FullPath
' Dim oPathExists = From oFile In _OpenDocuments
' Where oFile.FullPath = oFullPath And oFile.Contents IsNot Nothing
' Select oFile
' If oPathExists.Count > 0 Then
' Dim oDocumentInfo = oPathExists.First()
' Dim oFileInfo As New FileInfo(DocumentInfo.FullPath)
' Dim oSizeChanged = False
' Dim oWriteTimeChanged = False
' If DocumentInfo.Contents Is Nothing Then
' oSizeChanged = False
' Else
' oSizeChanged = Not oFileInfo.Length.Equals(DocumentInfo.Contents?.Length)
' End If
' If DocumentInfo.LastWriteTime = Nothing Then
' oWriteTimeChanged = False
' Else
' oWriteTimeChanged = Not oFileInfo.LastWriteTime.Equals(DocumentInfo.LastWriteTime)
' End If
' If oSizeChanged Or oWriteTimeChanged Then
' Else
' Using oStream = File.OpenRead(oFullPath)
' Using oMemoryStream = New MemoryStream()
' oStream.CopyTo(oMemoryStream)
' oFileContents = oMemoryStream.ToArray()
' End Using
' End Using
' End If
' End If
' DocumentInfo.Contents = oFileContents
' DocumentInfo.LastWriteTime = oFileInfo.LastWriteTime
' Return DocumentInfo
' Catch ex As Exception
' _Logger.Error(ex)
' Return Nothing
' End Try
'End Function
Public Function RefreshResults(pResults As IEnumerable(Of BaseResult)) As Boolean Implements IResultForm.RefreshResults
_IsLoading = True
Try
@@ -517,12 +464,12 @@ Public Class frmDocumentResultList
End If
Dim oCreated, oChanged As String
If _Environment?.User?.Language <> "de-DE" Then
oChanged = "Changed"
oCreated = "Created"
Else
If _Language = State.UserState.LANG_DE_DE Then
oChanged = "Geändert"
oCreated = "Erstellt"
Else
oCreated = "Created"
oChanged = "Changed"
End If
Try
@@ -617,138 +564,140 @@ Public Class frmDocumentResultList
End If
End Sub
Private Sub BarButtonItemExportGrid1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemExportGrid1.ItemClick
Dim oActiveGrid = GetActiveGridControl()
Private Sub BarButtonItemExportGrid1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItemExportGrid1.ItemClick
Dim oActiveGrid = GetActiveGridControl()
If oActiveGrid IsNot Nothing Then
Dim oGridBand = _ActiveGridBand
If oActiveGrid IsNot Nothing Then
Dim oGridBand = _ActiveGridBand
XtraSaveFileDialog.FileName = Utils.ConvertTextToSlug(oGridBand.Caption) & ".xlsx"
XtraSaveFileDialog.DefaultExt = ".xlsx"
XtraSaveFileDialog.FileName = Utils.ConvertTextToSlug(oGridBand.Caption) & ".xlsx"
XtraSaveFileDialog.DefaultExt = ".xlsx"
If XtraSaveFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim oOptions As New XlsxExportOptions() With {
.ExportMode = XlsxExportMode.SingleFile
}
oActiveGrid.ExportToXlsx(XtraSaveFileDialog.FileName, oOptions)
End If
If XtraSaveFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim oOptions As New XlsxExportOptions() With {
.ExportMode = XlsxExportMode.SingleFile
}
oActiveGrid.ExportToXlsx(XtraSaveFileDialog.FileName, oOptions)
End If
Else
If _Language = State.UserState.LANG_DE_DE Then
MessageBox.Show("Bitte wählen Sie eine Tabelle aus, die Sie exportieren möchten", Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Bitte wählen Sie eine Tabelle aus, die Sie exportieren möchten", Text, MessageBoxButtons.OK)
MessageBox.Show("Please select a table that you want to export", Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
End If
End Sub
Private Sub SplitContainerControl1_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl1.SplitterPositionChanged
If _IsLoading = False Then
_Config.Config.SplitContainer1Distance = SplitContainerControl1.SplitterPosition
_Config.Save()
Private Sub SplitContainerControl1_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl1.SplitterPositionChanged
If _IsLoading = False Then
_Config.Config.SplitContainer1Distance = SplitContainerControl1.SplitterPosition
_Config.Save()
End If
End Sub
Private Sub SplitContainerControl2_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl2.SplitterPositionChanged
If _IsLoading = False Then
_Config.Config.SplitContainer2Distance = SplitContainerControl2.SplitterPosition
_Config.Save()
End If
End Sub
Private Function GetActiveRow() As DataRow
Dim oActiveGrid = GetActiveGridControl()
Dim oActiveRowhandle = _Helpers.ActiveRowHandle
If oActiveGrid IsNot Nothing And oActiveRowhandle <> Constants.NO_ROW_HANDLE Then
Dim oView = DirectCast(oActiveGrid.DefaultView, GridView)
Dim oRow = oView.GetDataRow(oActiveRowhandle)
Return oRow
Else
Return Nothing
End If
End Function
Private Function GetDevexpressGrid_LayoutName(pGridView As GridView)
Dim Filename As String = $"DevExpressGridViewDocResult_{pGridView.Name}UserLayout.xml"
Return Path.Combine(_Config.UserConfigPath.Replace("UserConfig.xml", ""), Filename)
End Function
Private Function GetActiveGridControl() As GridControl
If _ActiveGrid Is Nothing Then
Return Nothing
End If
Return _ActiveGrid
End Function
Private Sub GridViewSave_Layout(pGridView As GridView)
Try
Dim oXml As String = GetDevexpressGrid_LayoutName(pGridView)
pGridView.SaveLayoutToXml(oXml, OptionsLayoutBase.FullLayout)
Catch ex As Exception
_Logger.Error(ex)
_Logger.Info("Error while saving GridLayout: " & ex.Message)
End Try
End Sub
Private Sub RestoreLayout(pGridView As GridView)
Try
Dim oLayoutFile As String = GetDevexpressGrid_LayoutName(pGridView)
If File.Exists(oLayoutFile) Then
pGridView.RestoreLayoutFromXml(oLayoutFile, OptionsLayoutBase.FullLayout)
End If
End Sub
Catch ex As Exception
_Logger.Error(ex)
_Logger.Info("Error while restoring layout: " & ex.Message)
End Try
End Sub
Private Sub SplitContainerControl2_SplitterPositionChanged(sender As Object, e As EventArgs) Handles SplitContainerControl2.SplitterPositionChanged
If _IsLoading = False Then
_Config.Config.SplitContainer2Distance = SplitContainerControl2.SplitterPosition
_Config.Save()
Private Sub GridControl_Enter(sender As GridControl, e As EventArgs) Handles GridControl1.Enter, GridControl2.Enter, GridControl3.Enter
_ActiveGrid = sender
BarButtonItem5.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
BarButtonItemExportGrid1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
SetActiveGridBand()
End Sub
Private Sub GridView1_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged, GridView2.FocusedRowChanged, GridView3.FocusedRowChanged
Dim oGrid As GridControl = sender.GridControl
_ActiveGrid = oGrid
End Sub
Private Sub SetActiveGridBand()
If _ActiveGrid.Equals(GridControl1) Then
_ActiveGridBand = GridBand1
ElseIf _ActiveGrid.Equals(GridControl2) Then
_ActiveGridBand = GridBand2
ElseIf _ActiveGrid.Equals(GridControl3) Then
_ActiveGridBand = GridBand3
Else
_ActiveGridBand = Nothing
End If
End Sub
Private Sub OpenFolderPath()
Try
Dim oRow = GetActiveRow()
If oRow IsNot Nothing Then
Dim oFilename = _CurrentDocument.FullPath
Dim oDirectory = IO.Path.GetDirectoryName(oFilename)
Process.Start(oDirectory)
End If
End Sub
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Private Function GetActiveRow() As DataRow
Dim oActiveGrid = GetActiveGridControl()
Dim oActiveRowhandle = _Helpers.ActiveRowHandle
If oActiveGrid IsNot Nothing And oActiveRowhandle <> Constants.NO_ROW_HANDLE Then
Dim oView = DirectCast(oActiveGrid.DefaultView, GridView)
Dim oRow = oView.GetDataRow(oActiveRowhandle)
Return oRow
Else
Return Nothing
End If
End Function
Private Function GetDevexpressGrid_LayoutName(pGridView As GridView)
Dim Filename As String = $"DevExpressGridViewDocResult_{pGridView.Name}UserLayout.xml"
Return Path.Combine(_Config.UserConfigPath.Replace("UserConfig.xml", ""), Filename)
End Function
Private Function GetActiveGridControl() As GridControl
If _ActiveGrid Is Nothing Then
Return Nothing
Private Sub OpenFile()
Try
If _CurrentDocument IsNot Nothing Then
Dim oFilename = _CurrentDocument.FullPath
DocumentPropertyMenu_FileOpened(Me, oFilename)
End If
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Return _ActiveGrid
End Function
Private Sub GridViewSave_Layout(pGridView As GridView)
Try
Dim oXml As String = GetDevexpressGrid_LayoutName(pGridView)
pGridView.SaveLayoutToXml(oXml, OptionsLayoutBase.FullLayout)
Catch ex As Exception
_Logger.Error(ex)
_Logger.Info("Error while saving GridLayout: " & ex.Message)
End Try
End Sub
Private Sub RestoreLayout(pGridView As GridView)
Try
Dim oLayoutFile As String = GetDevexpressGrid_LayoutName(pGridView)
If File.Exists(oLayoutFile) Then
pGridView.RestoreLayoutFromXml(oLayoutFile, OptionsLayoutBase.FullLayout)
End If
Catch ex As Exception
_Logger.Error(ex)
_Logger.Info("Error while restoring layout: " & ex.Message)
End Try
End Sub
Private Sub GridControl_Enter(sender As GridControl, e As EventArgs) Handles GridControl1.Enter, GridControl2.Enter, GridControl3.Enter
_ActiveGrid = sender
BarButtonItem5.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
BarButtonItemExportGrid1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
SetActiveGridBand()
End Sub
Private Sub GridView1_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs) Handles GridView1.FocusedRowChanged, GridView2.FocusedRowChanged, GridView3.FocusedRowChanged
Dim oGrid As GridControl = sender.GridControl
_ActiveGrid = oGrid
End Sub
Private Sub SetActiveGridBand()
If _ActiveGrid.Equals(GridControl1) Then
_ActiveGridBand = GridBand1
ElseIf _ActiveGrid.Equals(GridControl2) Then
_ActiveGridBand = GridBand2
ElseIf _ActiveGrid.Equals(GridControl3) Then
_ActiveGridBand = GridBand3
Else
_ActiveGridBand = Nothing
End If
End Sub
Private Sub OpenFolderPath()
Try
Dim oRow = GetActiveRow()
If oRow IsNot Nothing Then
Dim oFilename = _CurrentDocument.FullPath
Dim oDirectory = IO.Path.GetDirectoryName(oFilename)
Process.Start(oDirectory)
End If
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Private Sub OpenFile()
Try
If _CurrentDocument IsNot Nothing Then
Dim oFilename = _CurrentDocument.FullPath
DocumentPropertyMenu_FileOpened(Me, oFilename)
End If
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Private Sub CopyFileName()
Private Sub CopyFileName()
Try
Dim oRow = GetActiveRow()
@@ -840,99 +789,63 @@ Public Class frmDocumentResultList
End Try
End Sub
Public Sub DocumentPropertyMenu_FileOpened(sender As Object, FilePath As String)
'DocumentViewer1.CloseDocument()
Dim oProcess = Process.Start(New ProcessStartInfo With {
Public Sub DocumentPropertyMenu_FileOpened(sender As Object, FilePath As String)
Dim oProcess = Process.Start(New ProcessStartInfo With {
.FileName = FilePath
})
End Sub
End Sub
Public Sub FileOpenTimer_Elapsed() Handles _FileOpenTimer.Tick
'Try
' Dim oProcesses = Process.GetProcesses()
' Dim oIds = (From oProc In oProcesses
' Select oProc.Id).
' ToList()
' Dim oNewFileOpenList As New Dictionary(Of Integer, String)
' For Each oOpenFile In _FileOpenList
' If oIds.Contains(oOpenFile.Key) Then
' oNewFileOpenList.Add(oOpenFile.Key, oOpenFile.Value)
' End If
' Next
' If oNewFileOpenList.Count < _FileOpenList.Count Then
' Dim oClosedFiles = _FileOpenList.
' Except(oNewFileOpenList).
' ToList()
' If oClosedFiles.Count = 1 Then
' Dim oOpenFile = oClosedFiles.First()
' DocumentViewer1.LoadFile(oOpenFile.Value)
' Else
' ClearGridData()
' UpdateGridData()
' End If
' _FileOpenList = oNewFileOpenList
' End If
'Catch ex As Exception
' _Logger.Error(ex)
'End Try
End Sub
Public Sub Show_CriticalError(Message As String)
Public Sub Show_CriticalError(Message As String)
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
labelCriticalError.Caption = Message
End Sub
Public Sub Show_Warning(Message As String)
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
labelWarning.Caption = Message
End Sub
Public Sub Show_Warning(Message As String)
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
labelWarning.Caption = Message
End Sub
Public Sub Reset_Errors()
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End Sub
Public Sub Reset_Errors()
labelCriticalError.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
labelWarning.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End Sub
Private Sub BarButtonItem5_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem5.ItemClick
If Not IsNothing(_ActiveGrid) Then
Try
Dim oFile = GetDevexpressGrid_LayoutName(_ActiveGrid.MainView)
If File.Exists(oFile) Then
File.Delete(oFile)
End If
UpdateGridData()
Catch ex As Exception
_Logger.Error(ex)
End Try
End If
End Sub
Private Sub BarButtonItem5_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem5.ItemClick
If Not IsNothing(_ActiveGrid) Then
Try
Dim oFile = GetDevexpressGrid_LayoutName(_ActiveGrid.MainView)
If File.Exists(oFile) Then
File.Delete(oFile)
End If
UpdateGridData()
Catch ex As Exception
_Logger.Error(ex)
End Try
End If
End Sub
Private Sub frmDocumentResultList_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
GridViewSave_Layout(_ActiveGrid.MainView)
End Sub
Private Sub frmDocumentResultList_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
GridViewSave_Layout(_ActiveGrid.MainView)
End Sub
Private _DragBoxFromMouseDown As Rectangle
Private _ScreenOffset As Point
Private _DragBoxFromMouseDown As Rectangle
Private _ScreenOffset As Point
Private Sub GridView1_MouseDown(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseDown
If sender.FocusedRowHandle >= 0 Then
Dim oDragSize As Size = SystemInformation.DragSize
Private Sub GridView1_MouseDown(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseDown
If sender.FocusedRowHandle >= 0 Then
Dim oDragSize As Size = SystemInformation.DragSize
_DragBoxFromMouseDown = New Rectangle(New Point(e.X - (oDragSize.Width / 2),
e.Y - (oDragSize.Height / 2)), oDragSize)
_DragBoxFromMouseDown = New Rectangle(New Point(e.X - (oDragSize.Width / 2),
e.Y - (oDragSize.Height / 2)), oDragSize)
Else
_DragBoxFromMouseDown = Rectangle.Empty
End If
End Sub
Private Sub GridView1_MouseUp(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseUp
Else
_DragBoxFromMouseDown = Rectangle.Empty
End Sub
End If
End Sub
Private Sub GridView1_MouseUp(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseUp
_DragBoxFromMouseDown = Rectangle.Empty
End Sub
Private Sub GridView1_MouseMove(sender As GridView, e As MouseEventArgs) Handles GridView1.MouseMove
If e.Button AndAlso e.Button = MouseButtons.Left Then