diff --git a/GUIs.ZooFlow/ApplicationEvents.vb b/GUIs.ZooFlow/ApplicationEvents.vb index cb6d4709..12bfb84b 100644 --- a/GUIs.ZooFlow/ApplicationEvents.vb +++ b/GUIs.ZooFlow/ApplicationEvents.vb @@ -70,12 +70,10 @@ Namespace My End Sub Public Sub App_Shutdown(sender As Object, e As EventArgs) Handles Me.Shutdown - _Logger.Debug("Shutting down Client Suite..") - Application.Sidebar.UnregisterSidebar() + _Logger.Debug("Shutting down Zooflow..") End Sub Private Sub MyApplication_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs) Handles Me.UnhandledException - Application.Sidebar.UnregisterSidebar() _Logger.Warn("Unhandled exception occurred: [{0}]", e.Exception.Message) _Logger.Error(e.Exception) End Sub diff --git a/GUIs.ZooFlow/MyApplication.vb b/GUIs.ZooFlow/MyApplication.vb index 492f74fd..e4dae4eb 100644 --- a/GUIs.ZooFlow/MyApplication.vb +++ b/GUIs.ZooFlow/MyApplication.vb @@ -55,7 +55,7 @@ Namespace My Public Property IDB_ConnectionString As String Public Property Globix As New Globix.State Public Property Search As New Search.State - Public Property Sidebar As Sidebar + Public Property Sidebar As Sidebar2 Public CommandLineFunction As String Public CommandLineArguments As New Dictionary(Of String, String) diff --git a/GUIs.ZooFlow/Sidebar2.vb b/GUIs.ZooFlow/Sidebar2.vb new file mode 100644 index 00000000..f3cb8cb1 --- /dev/null +++ b/GUIs.ZooFlow/Sidebar2.vb @@ -0,0 +1,170 @@ +Imports System.Runtime.InteropServices + +Public Class Sidebar2 + + Private Shared Function SHAppBarMessage(ByVal dwMessage As Integer, ByRef BarrData As AppDeskBar) As Integer + End Function + + Public Shared Function RegisterWindowMessage(ByVal msg As String) As Integer + End Function + + + Structure RECT + Public left As Integer + Public top As Integer + Public right As Integer + Public bottom As Integer + End Structure + + Structure AppDeskBar + Public cbSize As Integer + Public hWnd As IntPtr + Public uCallbackMessage As Integer + Public uEdge As Integer + Public rc As RECT + Public lParam As IntPtr + End Structure + + Public Enum ABMsg + ABM_NEW = 0 + ABM_REMOVE = 1 + ABM_QUERYPOS = 2 + ABM_SETPOS = 3 + ABM_GETSTATE = 4 + ABM_GETTASKBARPOS = 5 + ABM_ACTIVATE = 6 + ABM_GETAUTOHIDEBAR = 7 + ABM_SETAUTOHIDEBAR = 8 + ABM_WINDOWPOSCHANGED = 9 + ABM_SETSTATE = 10 + End Enum + Public Enum ABEdge + ABE_LEFT = 0 + ABE_TOP = 1 + ABE_RIGHT = 2 + ABE_BOTTOM = 3 + End Enum + Public Enum ABNotify + ABN_STATECHANGE = 0 + ABN_POSCHANGED = 1 + ABN_FULLSCREENAPP = 2 + ABN_WINDOWARRANGE = 3 + End Enum + + Private AppDeskData As AppDeskBar + Private fBarRegistered As Boolean = False + Private Form As Form + + Public ReadOnly Property SidebarRegistered As Boolean + Get + Return fBarRegistered + End Get + End Property + + Public Property uCallBack As Integer + + Public Sub New(pForm As Form) + Form = pForm + End Sub + + Public Sub RegisterBar(dockEdge As ABEdge) + AppDeskData = New AppDeskBar() + AppDeskData.cbSize = Marshal.SizeOf(AppDeskData) + AppDeskData.hWnd = Form.Handle + If Not fBarRegistered Then + fBarRegistered = True + + Form.FormBorderStyle = FormBorderStyle.None + Form.ShowInTaskbar = False + + uCallBack = RegisterWindowMessage("AppBarMessage") + AppDeskData.uCallbackMessage = uCallBack + + 'ToDo: Unsigned Integers not supported + SHAppBarMessage(CInt(ABMsg.ABM_NEW), AppDeskData) + + ABSetPos(dockEdge) + Else + SHAppBarMessage(CInt(ABMsg.ABM_REMOVE), AppDeskData) + fBarRegistered = False + End If + End Sub + + Public Sub UnregisterSidebar() + If fBarRegistered = True Then + fBarRegistered = False + + Form.FormBorderStyle = FormBorderStyle.Sizable + Form.ShowInTaskbar = True + + '----NEW + Dim abd As New AppDeskBar() + abd.cbSize = Marshal.SizeOf(abd) + abd.hWnd = Form.Handle + + ' TODO: Save and restore width and taskbar + 'Me.Width = 305 + 'Me.Height = 85 + 'Me.ShowInTaskbar = True + SHAppBarMessage(ABMsg.ABM_REMOVE, abd) + End If + End Sub + + Public Sub ABSetPos(dockEdge As ABEdge) + Dim abd As New AppDeskBar() + abd.cbSize = Marshal.SizeOf(abd) + abd.hWnd = Form.Handle + abd.uEdge = CInt(dockEdge) + + If abd.uEdge = CInt(ABEdge.ABE_LEFT) Or abd.uEdge = CInt(ABEdge.ABE_RIGHT) Then + abd.rc.top = 0 + abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height + If abd.uEdge = CInt(ABEdge.ABE_LEFT) Then + abd.rc.left = 0 + abd.rc.right = Form.Size.Width + Else + abd.rc.right = SystemInformation.PrimaryMonitorSize.Width + abd.rc.left = abd.rc.right - Form.Size.Width + End If + Else + abd.rc.left = 0 + abd.rc.right = SystemInformation.PrimaryMonitorSize.Width + If abd.uEdge = CInt(ABEdge.ABE_TOP) Then + abd.rc.top = 0 + abd.rc.bottom = Form.Size.Height + Else + abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height + abd.rc.top = abd.rc.bottom - Form.Size.Height + End If + End If + + ' Query the system for an approved size and position. + SHAppBarMessage(CInt(ABMsg.ABM_QUERYPOS), abd) + + ' Adjust the rectangle, depending on the edge to which the + ' appbar is anchored. + Select Case abd.uEdge + Case CInt(ABEdge.ABE_LEFT) + abd.rc.right = abd.rc.left + Form.Size.Width + Case CInt(ABEdge.ABE_RIGHT) + abd.rc.left = abd.rc.right - Form.Size.Width + Case CInt(ABEdge.ABE_TOP) + abd.rc.bottom = abd.rc.top + Form.Size.Height + Case CInt(ABEdge.ABE_BOTTOM) + abd.rc.top = abd.rc.bottom - Form.Size.Height + End Select + + ' Pass the final bounding rectangle to the system. + SHAppBarMessage(CInt(ABMsg.ABM_SETPOS), abd) + + ' Move and size the appbar so that it conforms to the + ' bounding rectangle passed to the system. + Form.Location = New Point(abd.rc.left, abd.rc.top) + Dim PSBH = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height + Dim TaskBarHeight = PSBH - System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height + Form.Height = Screen.PrimaryScreen.Bounds.Height - TaskBarHeight + + ' MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, True) + End Sub + +End Class diff --git a/GUIs.ZooFlow/ZooFlow.vbproj b/GUIs.ZooFlow/ZooFlow.vbproj index 1fce6115..60f58fe9 100644 --- a/GUIs.ZooFlow/ZooFlow.vbproj +++ b/GUIs.ZooFlow/ZooFlow.vbproj @@ -412,6 +412,7 @@ + frmAdmin_ClipboardWatcher.vb diff --git a/GUIs.ZooFlow/frmFlowForm.Designer.vb b/GUIs.ZooFlow/frmFlowForm.Designer.vb index 48cf185f..deaf2f27 100644 --- a/GUIs.ZooFlow/frmFlowForm.Designer.vb +++ b/GUIs.ZooFlow/frmFlowForm.Designer.vb @@ -1,8 +1,9 @@ -Imports DigitalData.GUIs.Common.Base +Imports DevExpress.XtraEditors +Imports DigitalData.GUIs.Common.Base Partial Class frmFlowForm - Inherits BaseForm + Inherits XtraForm 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. diff --git a/GUIs.ZooFlow/frmFlowForm.vb b/GUIs.ZooFlow/frmFlowForm.vb index 33d48744..11cd33ed 100644 --- a/GUIs.ZooFlow/frmFlowForm.vb +++ b/GUIs.ZooFlow/frmFlowForm.vb @@ -11,9 +11,135 @@ Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Language.Utils Imports DigitalData.Modules.Messaging Imports DigitalData.Modules.Windows +Imports DigitalData.GUIs.Common.Base Public Class frmFlowForm +#Region "Sidebar DllImport" + + Private Shared Function SHAppBarMessage(ByVal dwMessage As Integer, ByRef BarrData As AppDeskBar) As Integer + End Function + + Public Shared Function RegisterWindowMessage(ByVal msg As String) As Integer + End Function +#End Region +#Region "Sidebar Variablen" + Private AppDeskData As AppDeskBar + Private fBarRegistered As Boolean = False + Private Property uCallBack As Integer + + Private Structure RECT + Public left As Integer + Public top As Integer + Public right As Integer + Public bottom As Integer + End Structure + Private Structure AppDeskBar + Public cbSize As Integer + Public hWnd As IntPtr + Public uCallbackMessage As Integer + Public uEdge As Integer + Public rc As RECT + Public lParam As IntPtr + End Structure + Private Enum ABMsg + ABM_NEW = 0 + ABM_REMOVE = 1 + ABM_QUERYPOS = 2 + ABM_SETPOS = 3 + ABM_GETSTATE = 4 + ABM_GETTASKBARPOS = 5 + ABM_ACTIVATE = 6 + ABM_GETAUTOHIDEBAR = 7 + ABM_SETAUTOHIDEBAR = 8 + ABM_WINDOWPOSCHANGED = 9 + ABM_SETSTATE = 10 + End Enum + Public Enum ABEdge + ABE_LEFT = 0 + ABE_TOP + ABE_RIGHT + ABE_BOTTOM + End Enum + Private Enum ABNotify + ABN_STATECHANGE = 0 + ABN_POSCHANGED + ABN_FULLSCREENAPP + ABN_WINDOWARRANGE + End Enum +#End Region + +#Region "Sidebar Enum Properties Register" + Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) + If m.Msg = uCallBack Then + Select Case m.WParam.ToInt32() + Case CInt(ABNotify.ABN_POSCHANGED) + ABSetPos(ABEdge.ABE_RIGHT) + End Select + End If + MyBase.WndProc(m) + End Sub + Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams + Get + Dim cp As CreateParams = MyBase.CreateParams + cp.Style = cp.Style And Not &HC00000 ' WS_CAPTION + cp.Style = cp.Style And Not &H800000 ' WS_BORDER + cp.ExStyle = &H80 Or &H8 ' WS_EX_TOOLWINDOW | WS_EX_TOPMOST + Return cp + End Get + End Property + + Private Sub ABSetPos(ByVal dockEdge As ABEdge) + Dim abd As New AppDeskBar() + abd.cbSize = Marshal.SizeOf(abd) + abd.hWnd = Me.Handle + abd.uEdge = CInt(dockEdge) + If abd.uEdge = CInt(ABEdge.ABE_LEFT) Or abd.uEdge = CInt(ABEdge.ABE_RIGHT) Then + abd.rc.top = 0 + abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height + If abd.uEdge = CInt(ABEdge.ABE_LEFT) Then + abd.rc.left = 0 + abd.rc.right = Size.Width + Else + abd.rc.right = SystemInformation.PrimaryMonitorSize.Width + abd.rc.left = abd.rc.right - Size.Width + End If + Else + abd.rc.left = 0 + abd.rc.right = SystemInformation.PrimaryMonitorSize.Width + If abd.uEdge = CInt(ABEdge.ABE_TOP) Then + abd.rc.top = 0 + abd.rc.bottom = Size.Height + Else + abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height + abd.rc.top = abd.rc.bottom - Size.Height + End If + End If + ' Query the system for an approved size and position. + SHAppBarMessage(CInt(ABMsg.ABM_QUERYPOS), abd) + ' Adjust the rectangle, depending on the edge to which the + ' appbar is anchored. + Select Case abd.uEdge + Case CInt(ABEdge.ABE_LEFT) + abd.rc.right = abd.rc.left + Size.Width + Case CInt(ABEdge.ABE_RIGHT) + abd.rc.left = abd.rc.right - Size.Width + Case CInt(ABEdge.ABE_TOP) + abd.rc.bottom = abd.rc.top + Size.Height + Case CInt(ABEdge.ABE_BOTTOM) + abd.rc.top = abd.rc.bottom - Size.Height + End Select + ' Pass the final bounding rectangle to the system. + SHAppBarMessage(CInt(ABMsg.ABM_SETPOS), abd) + ' Move and size the appbar so that it conforms to the + ' bounding rectangle passed to the system. + + Me.Location = New Point(abd.rc.left, abd.rc.top) + Dim PSBH = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height + Dim TaskBarHeight = PSBH - System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height + Me.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height - TaskBarHeight + End Sub +#End Region ' Constants Private Const OPACITY_INITIAL = 0 @@ -25,6 +151,8 @@ Public Class frmFlowForm ' Common Helpers Classes Private Init As ClassInit Private FileClass As Filesystem.File + Private ErrorHandler As BaseErrorHandler + Private Logger As Logger ' Globix Helper Classes Private FileDrop As ClassFileDrop @@ -35,11 +163,6 @@ Public Class frmFlowForm Private ClassWindow As Window Private ProfileFilter As ProfileFilter Private ProfileLoader As ClassProfileLoader - 'Private Animator As New Animator() With { - ' .PopupColor = Color.FromArgb(255, 214, 49), - ' .PopupOpacity = 0.8, - ' .PopupSize = New Size(100, 30) - '} ' Runtime Flags Private ApplicationLoading As Boolean = True @@ -50,22 +173,11 @@ Public Class frmFlowForm Private IndexForm As frmGlobix_Index Private AdminForm As frmAdmin_Start - ' Events Public Event ClipboardChanged As EventHandler(Of IDataObject) Private WithEvents HotkeyClass As Hotkey Private WithEvents Watcher As Watcher = Watcher.Singleton - Public Sub New() - MyBase.New(My.LogConfig) - - ' Dieser Aufruf ist für den Designer erforderlich. - InitializeComponent() - - ' === Hide form initially === - Opacity = OPACITY_INITIAL - End Sub - Private Sub frmFlowForm_Load(sender As Object, e As EventArgs) Handles Me.Load ' === Show Splash Screen === SplashScreenManager.ShowForm(Me, GetType(frmSplash), False, False) @@ -75,9 +187,12 @@ Public Class frmFlowForm AddHandler Init.Completed, AddressOf Init_Completed Init.InitializeApplication() - ' Register Form as Sidebar - My.Application.Sidebar = New Sidebar(Handle) - My.Application.Sidebar.RegisterSidebar(My.UIConfig.SidebarScreen) + ' === 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) @@ -86,6 +201,15 @@ Public Class frmFlowForm ApplicationLoading = False SplashScreenManager.CloseForm(False) + ' === Initialize Error Handler === + Logger = My.LogConfig.GetLogger() + ErrorHandler = New BaseErrorHandler(My.LogConfig, Logger, Me) + + ' Register Form as Sidebar + My.Application.Sidebar = New Sidebar2(Me) + My.Application.Sidebar.RegisterBar(Sidebar2.ABEdge.ABE_RIGHT) + 'RegisterBar(ABEdge.ABE_RIGHT) + ' === Setup Timers === AddHandler TimerRefreshData.Tick, AddressOf TimerRefreshData_Tick TimerRefreshData.Enabled = True @@ -93,13 +217,6 @@ Public Class frmFlowForm ' === Register As Event Listener === EventBus.Instance.Register(Me) - ' === Set Form Properties === - TopMost = True - AllowDrop = True - ShowInTaskbar = False - Opacity = OPACITY_SHOWN - Location = My.UIConfig.FlowForm.Location - ' === Setup Event Handlers === AddHandler KeyDown, AddressOf frmFlowForm_KeyDown AddHandler KeyUp, AddressOf frmFlowForm_KeyDown @@ -187,6 +304,29 @@ Public Class frmFlowForm Me.Cursor = Cursors.Default End Sub + Public Sub RegisterBar(ByVal dockEdge As ABEdge) + AppDeskData = New AppDeskBar() + AppDeskData.cbSize = Marshal.SizeOf(AppDeskData) + AppDeskData.hWnd = Me.Handle + If Not fBarRegistered Then + uCallBack = RegisterWindowMessage("AppBarMessage") + AppDeskData.uCallbackMessage = uCallBack + SHAppBarMessage(CInt(ABMsg.ABM_NEW), AppDeskData) 'ToDo: Unsigned Integers not supported + fBarRegistered = True + ABSetPos(ABEdge.ABE_RIGHT) + Else + SHAppBarMessage(CInt(ABMsg.ABM_REMOVE), AppDeskData) + fBarRegistered = False + End If + End Sub + + Public Sub UnregisterBar() + If fBarRegistered Then + fBarRegistered = False + SHAppBarMessage(ABMsg.ABM_REMOVE, AppDeskData) + End If + End Sub + Public Sub Init_Folderwatch() Try Dim oSql As String = "SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'DEFAULT' AND USER_ID = " & My.Application.User.UserId @@ -286,6 +426,7 @@ Public Class frmFlowForm Public Sub OnEvent(Params As Object) Logger.Debug("OnEvent called!") End Sub + Private Sub PictureBox1_Click(sender As Object, e As EventArgs) frmSearchNeu.Show() @@ -897,5 +1038,11 @@ Public Class frmFlowForm Private Sub TestFlowSearchToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TestFlowSearchToolStripMenuItem.Click Open_FlowSearch() End Sub + + Private Sub ShowErrorMessage(pEx As Exception) + Dim oCallingClass = LogConfig.GetClassFullName(IncludeMethodNames:=True, Parts:=2) + ErrorHandler.ShowErrorMessage(pEx, oCallingClass) + End Sub + End Class