sammelrechnungsdruck, ustva, etc.

This commit is contained in:
2025-03-03 16:09:02 +01:00
parent 051cf0fce7
commit 2c906976cb
20 changed files with 2360 additions and 431 deletions

View File

@@ -1,6 +1,7 @@
Imports System.Windows.Forms
Imports System.IO
Imports Microsoft.Office.Interop
Imports System.Drawing
Public Class usrcntlPDFScanList
Public Property _DATENSERVER_KATEGORIE As String = "DOKUMENTE"
@@ -27,6 +28,8 @@ Public Class usrcntlPDFScanList
Public Event FileAdded(id As String, path As String, name As String)
Public Event FileDeleted()
Private draggedFilePath As String = ""
Private Sub usrcntlPDFScan_Layout(sender As Object, e As LayoutEventArgs) Handles Me.Layout
' Me.txt.Text = _TEXT_PDF
Me.MyListBox1.Dock = DockStyle.Fill
@@ -401,9 +404,58 @@ Public Class usrcntlPDFScanList
End Sub
Private Function GetFolderUnderCursor() As String
Try
Dim cursorPos As Point = Cursor.Position
Dim shell As Object = CreateObject("Shell.Application")
Dim folder As Object = shell.Namespace(0) ' Desktop level
' Get all open Explorer windows
For Each window In shell.Windows()
Dim explorerPath As String = window.Document.Folder.Self.Path
If Not String.IsNullOrEmpty(explorerPath) Then
' Check if the cursor is within the window bounds
Dim rect As Rectangle = New Rectangle(window.Left, window.Top, window.Width, window.Height)
If rect.Contains(cursorPos) Then
Return explorerPath ' Return detected folder path
End If
End If
Next
Catch ex As Exception
Return ""
End Try
Return ""
End Function
Private Sub cntxt_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles cntxt.Opening
UmbenennenToolStripMenuItem.Visible = (MyListBox1.SelectedItems.Count = 1)
End Sub
Private Sub usrcntlPDFScanList_DragLeave(sender As Object, e As EventArgs) 'Handles MyBase.DragLeave
If Not String.IsNullOrEmpty(draggedFilePath) Then
Try
' Get the folder path where the cursor moved
Dim cursorPath As String = GetFolderUnderCursor()
If Not String.IsNullOrEmpty(cursorPath) AndAlso Directory.Exists(cursorPath) Then
' Copy file to the detected folder
Dim destinationPath As String = Path.Combine(cursorPath, Path.GetFileName(draggedFilePath))
File.Copy(draggedFilePath, destinationPath, True)
MessageBox.Show("PDF saved to: " & destinationPath, "File Saved", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Could not determine the target folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Catch ex As Exception
MessageBox.Show("Error saving PDF: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
End Class