Imports DevExpress.Utils Imports DevExpress.XtraBars.Docking2010.Views Imports DevExpress.XtraBars.Ribbon Imports DevExpress.XtraGrid Imports DevExpress.XtraGrid.Views.Grid Imports DevExpress.XtraGrid.Views.Grid.ViewInfo Imports DevExpress.XtraTab Imports DigitalData.Modules.Logging Public Class frmAdmin_Start Inherits frmAdmin_Base Private Const IDB_START = "IDB_START" Private Const IDB_ATTRIBUTES = "IDB_ATTRIBUTES" Private Const IDB_BUSINESS_ENTITY = "IDB_BUSINESS_ENTITY" Private Const GLOBIX = "GLOBIX" Private Const CLIPBOARD_WATCHER = "CLIPBOARD_WATCHER" Private PrimaryKey As String = Nothing Private SourceCommands As New Dictionary(Of String, SourceSql) Private CurrentPage As String Private Class SourceSql Public Title As String Public SQL As String Public PrimaryKey As String End Class Private Sub frmAdministration_Load(sender As Object, e As EventArgs) Handles MyBase.Load Load_SourceSql() TreeListMenu.ExpandAll() ' Show Tab Header in Development, hide when running the app XtraTabControl.ShowTabHeader = DefaultBoolean.False End Sub Private Sub Load_SourceSql() Dim oTable As DataTable = My.Database.GetDatatable("SELECT * FROM TBZF_ADMIN_SOURCE_SQL") For Each oRow As DataRow In oTable.Rows Dim oSource As New SourceSql With { .PrimaryKey = oRow.Item("PK_COLUMN"), .SQL = oRow.Item("SQL_COMMAND"), .Title = oRow.Item("ENTITY_TITLE") } SourceCommands.Add(oRow.Item("ENTITY_TITLE"), oSource) Next End Sub Sub Display_Tab(pPageToDisplay As XtraTabPage, pTabControl As XtraTabControl) Try For Each oDocument As XtraTabPage In pTabControl.TabPages If oDocument.Name = pPageToDisplay.Name Then oDocument.PageVisible = True Else oDocument.PageVisible = False End If Next Catch ex As Exception ShowError(ex) End Try End Sub Sub Display_RibbonPage(PageToDisplay As RibbonPage) Try For Each oPage As RibbonPage In RibbonControl1.Pages If oPage.Name = PageToDisplay.Name Then oPage.Visible = True Else oPage.Visible = False End If Next Catch ex As Exception ShowError(ex) End Try End Sub Private Sub TreeList1_FocusedNodeChanged(sender As Object, e As DevExpress.XtraTreeList.FocusedNodeChangedEventArgs) Handles TreeListMenu.FocusedNodeChanged Try If e.Node Is Nothing OrElse e.Node.Tag Is Nothing Then Exit Sub End If CurrentPage = e.Node.Tag.ToString Dim oSource As SourceSql = SourceCommands.Item(CurrentPage) Select Case e.Node.Tag.ToString Case IDB_START Display_Tab(XtraTabPage_IDB, XtraTabControl) Case IDB_ATTRIBUTES Display_Tab(XtraTabPage_IDB, XtraTabControl) Display_Tab(XtraTabPageIDB_Attributes_New, XtraTabControlIDB) Dim oTable As DataTable = My.Database.GetDatatable(oSource.SQL) Load_Grid(oTable, oSource.PrimaryKey, GridAttributes) Case IDB_BUSINESS_ENTITY 'DisplayTab(XtraTabPage_Entities) Case GLOBIX Display_Tab(XtraTabPage_GlobalIndexer, XtraTabControl) Display_RibbonPage(RibbonPage_GlobalIndexer) Case CLIPBOARD_WATCHER Display_Tab(XtraTabPage_ClipboardWatcher, XtraTabControl) Display_RibbonPage(RibbonPage_ClipboardWatcher) End Select Catch ex As Exception ShowError(ex) End Try End Sub Private Sub Load_Grid(DataSource As DataTable, PrimaryKey As String, GridControl As GridControl) Try Me.PrimaryKey = PrimaryKey GridControl.DataSource = DataSource GridControl.ForceInitialize() Dim oGridView = DirectCast(GridControl.DefaultView, GridView) With oGridView.Appearance.EvenRow .BackColor = Color.Gainsboro .Options.UseBackColor = True End With With oGridView.Appearance.FocusedCell .BackColor = Color.Gold .Options.UseBackColor = True End With With oGridView.Appearance.FocusedRow .BackColor = Color.Gold .Options.UseBackColor = True End With With oGridView.OptionsBehavior .Editable = False .ReadOnly = True End With With oGridView.OptionsClipboard .CopyColumnHeaders = DefaultBoolean.False End With With oGridView.OptionsFind .AlwaysVisible = True End With With oGridView.OptionsView .ShowAutoFilterRow = True .EnableAppearanceEvenRow = True .ShowIndicator = False End With AddHandler oGridView.KeyDown, Sub(sender As Object, e As KeyEventArgs) Dim oView As GridView = DirectCast(sender, GridView) If e.Control AndAlso e.KeyCode = Keys.C And e.Modifiers = Keys.Control Then Dim oCellValue = oView.GetRowCellValue(oView.FocusedRowHandle, oView.FocusedColumn) If oCellValue IsNot Nothing AndAlso oCellValue.ToString() <> String.Empty Then Clipboard.SetText(oCellValue.ToString) End If e.Handled = True End If End Sub oGridView.BestFitColumns() Catch ex As Exception ShowError(ex) End Try End Sub Private Sub ViewAttributes_DoubleClick(sender As Object, e As EventArgs) Handles ViewAttributes.DoubleClick Dim view As GridView = TryCast(sender, GridView) Dim hitInfo As GridHitInfo = view.CalcHitInfo((TryCast(e, DXMouseEventArgs)).Location) If hitInfo.InDataRow Then Try Dim oRow As DataRow = ViewAttributes.GetFocusedDataRow If oRow IsNot Nothing Then Dim oPrimaryKey As Integer = oRow.Item(PrimaryKey) LoadAttribute(oPrimaryKey) End If Catch ex As Exception ShowError(ex) End Try End If End Sub Private Sub LoadAttribute(PrimaryKey As Integer) Try Dim oForm As New frmAdmin_IDBAttribute(PrimaryKey) oForm.ShowDialog() If oForm.HasChanges Then Dim oSource As SourceSql = SourceCommands.Item(CurrentPage) Dim oTable As DataTable = My.Database.GetDatatable(oSource.SQL) Load_Grid(oTable, oSource.PrimaryKey, GridAttributes) End If Catch ex As Exception ShowError(ex) End Try End Sub Private Sub BarButtonItem7_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem7.ItemClick Try Dim oRow As DataRow = ViewAttributes.GetFocusedDataRow If oRow IsNot Nothing Then Dim oPrimaryKey As Integer = oRow.Item(PrimaryKey) LoadAttribute(oPrimaryKey) End If Catch ex As Exception ShowError(ex) End Try End Sub End Class