ZooFlow: Save Window Position, Fix FlowForm Designer, Add Logger
This commit is contained in:
@@ -1,20 +1,35 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Drawing.Imaging
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Messaging
|
||||
|
||||
Public Class frmFlowForm
|
||||
Private WithEvents Watcher As ClassClipboardWatcher = ClassClipboardWatcher.Singleton
|
||||
Private ActiveModules As List(Of String)
|
||||
Private Logger As Logger
|
||||
|
||||
Private ESCHitCount As Integer = 0
|
||||
Private CurrentState As OnFlowFormStateChangedEvent.FlowFormState = OnFlowFormStateChangedEvent.FlowFormState.Default
|
||||
|
||||
Public Event ClipboardChanged As EventHandler(Of IDataObject)
|
||||
|
||||
Public Sub New()
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
ActiveModules = New List(Of String)
|
||||
Logger = My.LogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
|
||||
Public Sub New(ActiveModules As List(Of String))
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
Me.ActiveModules = ActiveModules
|
||||
Logger = My.LogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
Private Sub frmFlowForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
@@ -22,7 +37,9 @@ Public Class frmFlowForm
|
||||
TopMost = True
|
||||
AllowDrop = True
|
||||
ShowInTaskbar = False
|
||||
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.Default)
|
||||
|
||||
SetFormLocation()
|
||||
SetFormState(OnFlowFormStateChangedEvent.FlowFormState.Default)
|
||||
|
||||
' === Register Events ===
|
||||
|
||||
@@ -38,17 +55,16 @@ Public Class frmFlowForm
|
||||
Try
|
||||
EventBus.Instance.Unregister(Me)
|
||||
Catch ex As Exception
|
||||
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Form_MouseClick(sender As Object, ByVal e As MouseEventArgs)
|
||||
If e.Button = MouseButtons.Right Then
|
||||
MsgBox("RightMouseClick", MsgBoxStyle.OkOnly)
|
||||
ContextMenuStrip1.Show(Cursor.Position)
|
||||
Else
|
||||
If CurrentState = OnFlowFormStateChangedEvent.FlowFormState.HasSearchResults Then
|
||||
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.Default)
|
||||
SetFormState(OnFlowFormStateChangedEvent.FlowFormState.Default)
|
||||
EventBus.Instance.PostEvent(New OnFlowFormInteractionEvent(OnFlowFormInteractionEvent.FlowFormInteraction.Click))
|
||||
End If
|
||||
End If
|
||||
@@ -57,16 +73,19 @@ Public Class frmFlowForm
|
||||
|
||||
Private Sub Form_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
|
||||
If e.Button = MouseButtons.Left Then
|
||||
Win32.ReleaseCapture()
|
||||
Win32.SendMessage(Handle, Win32.WM_NCLBUTTONDOWN, Win32.HTCAPTION, 0)
|
||||
ClassWin32.ReleaseCapture()
|
||||
ClassWin32.SendMessage(Handle, ClassWin32.WM_NCLBUTTONDOWN, ClassWin32.HTCAPTION, 0)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Form_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs)
|
||||
If e.KeyCode = Keys.Escape Then
|
||||
If ESCHitCount > 0 Then
|
||||
Dim result As DialogResult = MessageBox.Show("Exit Zooflow", "Please Varify", MessageBoxButtons.YesNo)
|
||||
If result = DialogResult.Yes Then
|
||||
Application.Exit()
|
||||
Else
|
||||
ESCHitCount = 0
|
||||
End If
|
||||
Else
|
||||
ESCHitCount += 1
|
||||
@@ -75,16 +94,15 @@ Public Class frmFlowForm
|
||||
If ActiveModules.Contains(ClassConstants.MODULE_ZOOFLOW) Then
|
||||
MsgBox("Search")
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub OnEvent(e As OnFlowFormStateChangedEvent)
|
||||
CurrentState = e.State
|
||||
SetFlowFormState(e.State)
|
||||
SetFormState(e.State)
|
||||
End Sub
|
||||
|
||||
Public Sub SetFlowFormState(State As OnFlowFormStateChangedEvent.FlowFormState)
|
||||
Public Sub SetFormState(State As OnFlowFormStateChangedEvent.FlowFormState)
|
||||
Select Case State
|
||||
Case OnFlowFormStateChangedEvent.FlowFormState.HasSearchResults
|
||||
SetBitmap(My.Resources.CW_GEFUNDEN_klein)
|
||||
@@ -95,6 +113,10 @@ Public Class frmFlowForm
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Public Sub SetFormLocation()
|
||||
Me.Location = My.UIConfig.FlowForm.Location
|
||||
End Sub
|
||||
|
||||
Private Sub frmFlowForm_DragOver(sender As Object, e As DragEventArgs) Handles Me.DragOver
|
||||
If Not ActiveModules.Contains(ClassConstants.MODULE_GLOBAL_INDEXER) Then
|
||||
e.Effect = DragDropEffects.None
|
||||
@@ -102,15 +124,15 @@ Public Class frmFlowForm
|
||||
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
|
||||
' Handle file dragged from Windows
|
||||
e.Effect = DragDropEffects.Copy
|
||||
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.HasFileDropped)
|
||||
SetFormState(OnFlowFormStateChangedEvent.FlowFormState.HasFileDropped)
|
||||
ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then
|
||||
' Handle a message dragged from Outlook
|
||||
e.Effect = DragDropEffects.Copy
|
||||
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.HasFileDropped)
|
||||
SetFormState(OnFlowFormStateChangedEvent.FlowFormState.HasFileDropped)
|
||||
ElseIf e.Data.GetDataPresent("aryFileGroupDescriptor") AndAlso (e.Data.GetDataPresent("FileContents")) Then
|
||||
' Handle a message dragged from Thunderbird?
|
||||
e.Effect = DragDropEffects.Copy
|
||||
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.HasFileDropped)
|
||||
SetFormState(OnFlowFormStateChangedEvent.FlowFormState.HasFileDropped)
|
||||
Else
|
||||
' Otherwise, do not handle
|
||||
e.Effect = DragDropEffects.None
|
||||
@@ -119,7 +141,7 @@ Public Class frmFlowForm
|
||||
End Sub
|
||||
|
||||
Private Sub frmFlowForm_DragLeave(sender As Object, e As EventArgs) Handles Me.DragLeave
|
||||
SetFlowFormState(OnFlowFormStateChangedEvent.FlowFormState.Default)
|
||||
SetFormState(OnFlowFormStateChangedEvent.FlowFormState.Default)
|
||||
End Sub
|
||||
|
||||
Private Sub Watcher_ClipboardChanged(sender As Object, e As IDataObject) Handles Watcher.ClipboardChanged
|
||||
@@ -128,10 +150,6 @@ Public Class frmFlowForm
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub frmFlowForm_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
|
||||
|
||||
End Sub
|
||||
|
||||
'''' <summary>
|
||||
'''' DragDrop Support
|
||||
'''' </summary>
|
||||
@@ -143,4 +161,51 @@ Public Class frmFlowForm
|
||||
|
||||
' MyBase.WndProc(m)
|
||||
'End Sub
|
||||
|
||||
Public Sub SetBitmap(ByVal bitmap As Bitmap)
|
||||
SetBitmap(bitmap, 255, bitmap.Width, bitmap.Height)
|
||||
End Sub
|
||||
|
||||
Public Sub SetBitmap(ByVal Bitmap As Bitmap, ByVal Opacity As Byte, ByVal Width As Integer, ByVal Height As Integer)
|
||||
If Bitmap.PixelFormat <> PixelFormat.Format32bppArgb Then
|
||||
Throw New ApplicationException("The bitmap must be 32ppp with alpha-channel.")
|
||||
End If
|
||||
|
||||
Dim oScreenDeviceContext As IntPtr = ClassWin32.GetDC(IntPtr.Zero)
|
||||
Dim oMemoryDeviceContext As IntPtr = ClassWin32.CreateCompatibleDC(oScreenDeviceContext)
|
||||
Dim oBitmap As IntPtr = IntPtr.Zero
|
||||
Dim oOldBitmap As IntPtr = IntPtr.Zero
|
||||
|
||||
Try
|
||||
oBitmap = Bitmap.GetHbitmap(Color.FromArgb(0))
|
||||
oOldBitmap = ClassWin32.SelectObject(oMemoryDeviceContext, oBitmap)
|
||||
Dim oSize As ClassWin32.Size = New ClassWin32.Size(Width, Height)
|
||||
Dim oPointSource As ClassWin32.Point = New ClassWin32.Point(0, 0)
|
||||
Dim oTopPos As ClassWin32.Point = New ClassWin32.Point(Left, Top)
|
||||
Dim oBlend As ClassWin32.BLENDFUNCTION = New ClassWin32.BLENDFUNCTION With {
|
||||
.BlendOp = ClassWin32.AC_SRC_OVER,
|
||||
.BlendFlags = 0,
|
||||
.SourceConstantAlpha = Opacity,
|
||||
.AlphaFormat = ClassWin32.AC_SRC_ALPHA
|
||||
}
|
||||
ClassWin32.UpdateLayeredWindow(Handle, oScreenDeviceContext, oTopPos, oSize, oMemoryDeviceContext, oPointSource, 0, oBlend, ClassWin32.ULW_ALPHA)
|
||||
Finally
|
||||
ClassWin32.ReleaseDC(IntPtr.Zero, oScreenDeviceContext)
|
||||
|
||||
If oBitmap <> IntPtr.Zero Then
|
||||
ClassWin32.SelectObject(oMemoryDeviceContext, oOldBitmap)
|
||||
ClassWin32.DeleteObject(oBitmap)
|
||||
End If
|
||||
|
||||
ClassWin32.DeleteDC(oMemoryDeviceContext)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Protected Overrides ReadOnly Property CreateParams As CreateParams
|
||||
Get
|
||||
Dim oParams As CreateParams = MyBase.CreateParams
|
||||
oParams.ExStyle = oParams.ExStyle Or &H80000
|
||||
Return oParams
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
Reference in New Issue
Block a user