diff --git a/GUIs.ZooFlow/Dialog1.vb b/GUIs.ZooFlow/Dialog1.vb index 90cf3fa1..6bff2a38 100644 --- a/GUIs.ZooFlow/Dialog1.vb +++ b/GUIs.ZooFlow/Dialog1.vb @@ -1,14 +1,14 @@ Imports System.Windows.Forms Public Class Dialog1 - Public Sub New(messagetext As String, otitle As String) + Public Sub New(pMessageText As String, pTitle As String) ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. - Me.lblMeldung.Text = messagetext - Me.Text = otitle + Me.lblMeldung.Text = pMessageText + Me.Text = pTitle End Sub Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click diff --git a/GUIs.ZooFlow/Search/SearchRunner.vb b/GUIs.ZooFlow/Search/SearchRunner.vb index 10b379b5..45a8d919 100644 --- a/GUIs.ZooFlow/Search/SearchRunner.vb +++ b/GUIs.ZooFlow/Search/SearchRunner.vb @@ -86,18 +86,18 @@ Public Class SearchRunner End Function Public Async Function RunWithSearchTerm(pSearchTerm As String) As Task(Of SearchResult) - Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, Nothing) + Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, Nothing, Nothing) End Function Public Async Function RunWithSearchTerm(pSearchTerm As String, pSearchTitle As String) As Task(Of SearchResult) - Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, pSearchTitle) + Return Await RunWithSearchTerm(pSearchTerm, Nothing, Nothing, Nothing, pSearchTitle) End Function Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date) As Task(Of SearchResult) - Return Await RunWithSearchTerm(pSearchTerm, pDateFrom, pDateTo, Nothing) + Return Await RunWithSearchTerm(pSearchTerm, pDateFrom, pDateTo, Nothing, Nothing) End Function - Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date, pSearchTitle As String) As Task(Of SearchResult) + Public Async Function RunWithSearchTerm(pSearchTerm As String, pDateFrom As Date, pDateTo As Date, pSearchTokens As IEnumerable(Of Search.SearchToken.AttributeValueToken), pSearchTitle As String) As Task(Of SearchResult) If pDateFrom.Equals(Date.MinValue) = False Then ExplicitDate = True End If @@ -106,6 +106,7 @@ Public Class SearchRunner Dim oWindowTitle = GetResultWindowString(pSearchTerm, pSearchTitle) Dim oParams = GetParams(oWindowTitle) Dim oDateConstraint = $"{_ActiveDateAttribute}~{_ActiveDateConstraint}" + Dim oUserId = My.Application.User.UserId If ExplicitDate Then Dim oDate2 As Date @@ -114,13 +115,27 @@ Public Class SearchRunner Else oDate2 = pDateFrom End If - Dim oProc = $"EXEC PRIDB_SEARCH_ADD_USR_DATE {My.Application.User.UserId},'{pDateFrom}','{oDate2}'" + Dim oProc = $"EXEC PRIDB_SEARCH_ADD_USR_DATE {oUserId},'{pDateFrom}','{oDate2}'" If Await My.Database.ExecuteNonQueryIDBAsync(oProc) = True Then oDateConstraint = $"{_ActiveDateAttribute}~DATEPART" End If End If - Dim oSQL = $"EXEC PRIDB_SEARCH_TEXT_GET_RESULTS {My.Application.User.UserId},'{oSearchTerm}','{oDateConstraint}'" + Await My.Database.ExecuteNonQueryIDBAsync($"DELETE FROM TBIDB_SEARCH_INPUT_USER WHERE USR_ID = {oUserId}") + + If pSearchTokens IsNot Nothing AndAlso pSearchTokens.Count > 0 Then + + For Each oToken In pSearchTokens + Dim oSQLInsert As String = $" + INSERT INTO [dbo].[TBIDB_SEARCH_INPUT_USER] ([USR_ID], [ATTR_ID], [ATTR_TITLE], [TERM_ID], [OPERATOR]) + VALUES ({oUserId}, {oToken.AttributeId}, '{oToken.AttributeTitle}', {oToken.TermId}, 'AND')" + + Dim oResult = Await My.Database.ExecuteNonQueryIDBAsync(oSQLInsert) + Next + + End If + + Dim oSQL = $"EXEC PRIDB_SEARCH_TEXT_GET_RESULTS {oUserId},'{oSearchTerm}','{oDateConstraint}'" If Await My.Database.ExecuteNonQueryIDBAsync(oSQL) = True Then Dim oDTDocResult = Await My.Database.GetDatatableIDBAsync(BaseSearchSQL) diff --git a/GUIs.ZooFlow/Search/Test/Search.vb b/GUIs.ZooFlow/Search/Test/Search.vb deleted file mode 100644 index e403bff5..00000000 --- a/GUIs.ZooFlow/Search/Test/Search.vb +++ /dev/null @@ -1,116 +0,0 @@ -Imports System.ComponentModel -Imports DevExpress.XtraEditors -Imports DigitalData.GUIs.ZooFlow.Search.SearchToken -Imports DigitalData.Modules.EDMI.API -Imports DigitalData.Modules.Logging -Imports DigitalData.Modules.ZooFlow.State - -Namespace Search - Public Class Search - Private ReadOnly _SearchQuery As New BindingList(Of SearchCriteria) - Private ReadOnly _LogConfig As LogConfig - Private ReadOnly _Database As DatabaseWithFallback - Private ReadOnly _UserState As UserState - - Private ReadOnly _OpEquals As New KeyValuePair(Of String, Object)("gleich", New AttributeOperatorToken(OperatorToken.Equals)) - Private ReadOnly _OpNotEquals As New KeyValuePair(Of String, Object)("nicht gleich", New AttributeOperatorToken(OperatorToken.NotEquals)) - Private ReadOnly _OpGreaterThan As New KeyValuePair(Of String, Object)("größer als", New AttributeOperatorToken(OperatorToken.GreaterThan)) - Private ReadOnly _OpLessThan As New KeyValuePair(Of String, Object)("kleiner als", New AttributeOperatorToken(OperatorToken.LessThan)) - Private ReadOnly _OpContains As New KeyValuePair(Of String, Object)("enthält", New AttributeOperatorToken(OperatorToken.Contains)) - - Public ReadOnly Property Query As BindingList(Of SearchCriteria) - - - - Private ReadOnly TokenListAttributes As New Dictionary(Of String, Object) - 'Private ReadOnly TokenListAttributes As New Dictionary(Of String, Object) From { - ' {"Rechnungsnummer", New AttributeKeyToken("InvoiceNo")}, - ' {"Rechnungsdatum", New AttributeKeyToken("InvoiceDate")}, - ' {"Kundennummer", New AttributeKeyToken("CustNo")} - '} - Private ReadOnly TokenListOperands As New Dictionary(Of String, Object) From { - {"gleich", New AttributeOperatorToken(OperatorToken.Equals)}, - {"nicht gleich", New AttributeOperatorToken(OperatorToken.NotEquals)}, - {"größer als", New AttributeOperatorToken(OperatorToken.Equals)}, - {"kleiner als", New AttributeOperatorToken(OperatorToken.Equals)}, - {"enthält", New AttributeOperatorToken(OperatorToken.Equals)} - } - Private ReadOnly TokenListAttrValues As New Dictionary(Of String, Object) - 'Private ReadOnly TokenListAttrValues As New Dictionary(Of String, Object) From { - ' {"1233", New AttributeValueToken(1233)}, - ' {"1234", New AttributeValueToken(1234)}, - ' {"1235", New AttributeValueToken(1235)}, - ' {"4711", New AttributeValueToken(4711)}, - ' {"4712", New AttributeValueToken(4712)} - '} - Private ReadOnly TokenListDate As New Dictionary(Of String, Object) From { - {"heute", New DateToken(Date.Now)}, - {"gestern", New DateToken(Date.Now.AddDays(-1))}, - {"letzte Woche", New DateToken(TimeSpan.FromDays(-7))}, - {"letzter Monat", New DateToken(TimeSpan.FromDays(-30))} - } - - Public InputMode As InputMode = InputMode.Default - - Public Sub New(pLogConfig As LogConfig, pUserState As UserState, pDatabase As DatabaseWithFallback) - _LogConfig = pLogConfig - _Database = pDatabase - _UserState = pUserState - End Sub - - Public Function GetAttributeTokens() As Dictionary(Of String, Object) - Dim oSQL = $"SELECT * FROM VWIDB_BE_ATTRIBUTE WHERE DEFAULT_SEARCH_ATTRIBUTE = 1 AND LANG_CODE = '{_UserState.Language}'" - Dim oTable = _Database.GetDatatable("VWIDB_BE_ATTRIBUTE", oSQL, Constants.DatabaseType.IDB, $"DEFAULT_SEARCH_ATTRIBUTE = 1 AND LANG_CODE = '{_UserState.Language}'") - Dim oTokens As New Dictionary(Of String, Object) - - For Each oRow As DataRow In oTable.rows - oTokens.Add(oRow.Item("ATTR_TITLE"), New AttributeKeyToken(oRow.Item("ATTR_ID"))) - Next - - Return oTokens - End Function - - Public Function GetValueTokensForAttribute() As Dictionary(Of String, Object) - Dim oSQL = $"EXEC PRIDB_SEARCH_AUTOSUGGEST '{_UserState.Language}', {_UserState.UserId}" - Dim oTable = _Database.GetDatatableIDB(oSQL) - Dim oTokens As New Dictionary(Of String, Object) - - For Each oRow As DataRow In oTable.Rows - Dim oTerm = oRow.Item("TERM") - If oTokens.ContainsKey(oTerm) = False Then - oTokens.Add(oTerm, New AttributeValueToken(oTerm)) - End If - Next - - Return oTokens - End Function - - Public Function GetOperatorTokens(pDataType As Type) As Dictionary(Of String, Object) - Dim oResult = New Dictionary(Of String, Object) - - Select Case pDataType.GetType - Case GetType(Date) - oResult.Add(_OpEquals.Key, _OpEquals.Value) - - Case GetType(Integer) - oResult.Add(_OpEquals.Key, _OpEquals.Value) - oResult.Add(_OpNotEquals.Key, _OpNotEquals.Value) - oResult.Add(_OpGreaterThan.Key, _OpGreaterThan.Value) - oResult.Add(_OpLessThan.Key, _OpLessThan.Value) - - Case GetType(Boolean) - oResult.Add(_OpEquals.Key, _OpEquals.Value) - oResult.Add(_OpNotEquals.Key, _OpNotEquals.Value) - - Case Else - oResult.Add(_OpEquals.Key, _OpEquals.Value) - oResult.Add(_OpNotEquals.Key, _OpNotEquals.Value) - oResult.Add(_OpContains.Key, _OpContains.Value) - - End Select - - Return oResult - End Function - - End Class -End Namespace diff --git a/GUIs.ZooFlow/Search/Test/SearchCriteria.vb b/GUIs.ZooFlow/Search/Test/SearchCriteria.vb index 007c8cfe..0a6b4362 100644 --- a/GUIs.ZooFlow/Search/Test/SearchCriteria.vb +++ b/GUIs.ZooFlow/Search/Test/SearchCriteria.vb @@ -2,7 +2,6 @@ Public Class SearchCriteria Public Property ParenLeft As String = "" Public Property Key As String - Public Property Op As SearchToken.OperatorToken = SearchToken.OperatorToken.Equals Public Property Value As Object Public Property ParentRight As String = "" Public Property JoinOperator As String = "AND" diff --git a/GUIs.ZooFlow/Search/Test/SearchToken.vb b/GUIs.ZooFlow/Search/Test/SearchToken.vb index 431f2662..c3b3cc58 100644 --- a/GUIs.ZooFlow/Search/Test/SearchToken.vb +++ b/GUIs.ZooFlow/Search/Test/SearchToken.vb @@ -1,70 +1,25 @@ Namespace Search Public Class SearchToken - Public Enum [ValueType] - AttributeName - AttributeValue - AttributeOperator - End Enum + Public Class AttributeValueToken + Public AttributeTitle As String + Public AttributeId As Integer + Public TermValue As String + Public TermId As Integer - Public Enum [InputMode] - [Default] - [Operator] - Value - End Enum + Public Overrides Function GetHashCode() As Integer + Return (TermId.GetHashCode & AttributeId.GetHashCode).GetHashCode() + End Function - Public Enum [OperatorToken] - Equals - NotEquals - GreaterThan - LessThan - Contains - End Enum - - Public MustInherit Class TokenValue - Public Value As Object - Public Type As [ValueType] + Public Overrides Function Equals(obj As Object) As Boolean + Return Me.GetHashCode() = DirectCast(obj, AttributeValueToken).GetHashCode() + End Function Public Overrides Function ToString() As String - Return Value.ToString() + Return $"{TermValue} ({AttributeTitle})" End Function End Class - Public Class AttributeKeyToken - Inherits TokenValue - - Public Sub New(pValue As Object) - Value = pValue - Type = ValueType.AttributeName - End Sub - End Class - - Public Class AttributeOperatorToken - Inherits TokenValue - - Public Sub New(pValue As Object) - Value = pValue - Type = ValueType.AttributeOperator - End Sub - End Class - - Public Class AttributeValueToken - Inherits TokenValue - - Public Sub New(pValue As Object) - Value = pValue - Type = ValueType.AttributeValue - End Sub - End Class - - Public Class DateToken - Inherits TokenValue - - Public Sub New(pValue As Object) - Value = pValue - Type = ValueType.AttributeValue - End Sub - End Class End Class End Namespace \ No newline at end of file diff --git a/GUIs.ZooFlow/Search/Test/frmSearchNeu.vb b/GUIs.ZooFlow/Search/Test/frmSearchNeu.vb index cc964b1d..01c90126 100644 --- a/GUIs.ZooFlow/Search/Test/frmSearchNeu.vb +++ b/GUIs.ZooFlow/Search/Test/frmSearchNeu.vb @@ -6,7 +6,6 @@ Imports DigitalData.GUIs.ZooFlow.Search.SearchToken Imports DigitalData.Modules.EDMI.API Public Class frmSearchNeu - Private Search As Search.Search Private Database As DatabaseWithFallback Private TokenListDefault As New Dictionary(Of String, Object) @@ -17,13 +16,12 @@ Public Class frmSearchNeu Private Sub XtraForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Database = New DatabaseWithFallback(My.LogConfig, My.Application.Service.Client, My.DatabaseECM, My.DatabaseIDB) - Search = New Search.Search(My.LogConfig, My.Application.User, Database) - Dim oTokens = Search.GetAttributeTokens() - AddTokens(SearchControl2, oTokens) + 'Dim oTokens = Search.GetAttributeTokens() + 'AddTokens(SearchControl2, oTokens) - GridControl1.DataSource = Search.Query - cmbSelect.SelectedIndex = 0 + 'GridControl1.DataSource = Search.Query + 'cmbSelect.SelectedIndex = 0 End Sub Private Sub SetTokens(Editor As TokenEdit, Tokens As Dictionary(Of String, Object)) @@ -52,69 +50,69 @@ Public Class frmSearchNeu End Sub Private Sub SetNewTokens(pEditor As TokenEdit) - Dim oLastToken = pEditor.GetTokenList().LastOrDefault() - pEditor.Properties.BeginUpdate() + 'Dim oLastToken = pEditor.GetTokenList().LastOrDefault() + 'pEditor.Properties.BeginUpdate() - If oLastToken IsNot Nothing Then - Select Case oLastToken.Value.GetType + 'If oLastToken IsNot Nothing Then + ' Select Case oLastToken.Value.GetType - Case GetType(AttributeKeyToken) - ' After the attribute key comes an operator - SetTokens(pEditor, Search.GetOperatorTokens(GetType(String))) - Search.InputMode = InputMode.Operator + ' Case GetType(AttributeKeyToken) + ' ' After the attribute key comes an operator + ' SetTokens(pEditor, Search.GetOperatorTokens(GetType(String))) + ' Search.InputMode = InputMode.Operator - Case GetType(AttributeOperatorToken) - ' After the attribute operator comes a value - SetTokens(pEditor, TokenListAttrValues) - Search.InputMode = InputMode.Value + ' Case GetType(AttributeOperatorToken) + ' ' After the attribute operator comes a value + ' SetTokens(pEditor, TokenListAttrValues) + ' Search.InputMode = InputMode.Value - Case GetType(AttributeValueToken) - ' After the attribute value comes another value - SetTokens(pEditor, TokenListAttrValues) - Search.InputMode = InputMode.Value + ' Case GetType(AttributeValueToken) + ' ' After the attribute value comes another value + ' SetTokens(pEditor, TokenListAttrValues) + ' Search.InputMode = InputMode.Value - Case Else - SetTokens(pEditor, TokenListDefault) - Search.InputMode = InputMode.Default + ' Case Else + ' SetTokens(pEditor, TokenListDefault) + ' Search.InputMode = InputMode.Default - End Select - Else - SetTokens(pEditor, TokenListDefault) - Search.InputMode = InputMode.Default - End If + ' End Select + 'Else + ' SetTokens(pEditor, TokenListDefault) + ' Search.InputMode = InputMode.Default + 'End If - pEditor.Properties.EndUpdate() + 'pEditor.Properties.EndUpdate() End Sub Private Sub SearchControl2_CustomDrawTokenGlyph(sender As Object, e As TokenEditCustomDrawTokenGlyphEventArgs) Handles SearchControl2.CustomDrawTokenGlyph - ' Set Background according to token type - Select Case e.Value.GetType() - Case GetType(AttributeKeyToken) - e.Graphics.FillRectangle(New SolidBrush(ColorTranslator.FromHtml("#F87171")), e.Bounds) + '' Set Background according to token type + 'Select Case e.Value.GetType() + ' Case GetType(AttributeKeyToken) + ' e.Graphics.FillRectangle(New SolidBrush(ColorTranslator.FromHtml("#F87171")), e.Bounds) - Case GetType(AttributeOperatorToken) - e.Graphics.FillRectangle(New SolidBrush(ColorTranslator.FromHtml("#34D399")), e.Bounds) + ' Case GetType(AttributeOperatorToken) + ' e.Graphics.FillRectangle(New SolidBrush(ColorTranslator.FromHtml("#34D399")), e.Bounds) - Case GetType(AttributeValueToken) - e.Graphics.FillRectangle(New SolidBrush(ColorTranslator.FromHtml("#60A5FA")), e.Bounds) - Case Else - End Select + ' Case GetType(AttributeValueToken) + ' e.Graphics.FillRectangle(New SolidBrush(ColorTranslator.FromHtml("#60A5FA")), e.Bounds) + ' Case Else + 'End Select - ' Draw the glyph on top - ' This fixes: https://supportcenter.devexpress.com/ticket/details/t215578/tokenedit-glyph-is-not-visible-when-customdrawtokentext-is-used - e.DefaultDraw() + '' Draw the glyph on top + '' This fixes: https://supportcenter.devexpress.com/ticket/details/t215578/tokenedit-glyph-is-not-visible-when-customdrawtokentext-is-used + 'e.DefaultDraw() End Sub Private Sub SearchControl2_KeyUp(sender As Object, e As KeyEventArgs) Handles SearchControl2.KeyUp - If Search.InputMode = InputMode.Value And e.KeyCode = Keys.Enter And SearchControl2.IsPopupOpen Then - Search.Query.Add(New SearchCriteria With { - .ParenLeft = False, - .Key = "test", - .Op = OperatorToken.Equals, - .Value = "test", - .ParentRight = False - }) - End If + 'If Search.InputMode = InputMode.Value And e.KeyCode = Keys.Enter And SearchControl2.IsPopupOpen Then + ' Search.Query.Add(New SearchCriteria With { + ' .ParenLeft = False, + ' .Key = "test", + ' .Op = OperatorToken.Equals, + ' .Value = "test", + ' .ParentRight = False + ' }) + 'End If End Sub Private Sub RibbonControl1_Click(sender As Object, e As EventArgs) Handles RibbonControl1.Click diff --git a/GUIs.ZooFlow/Search/frmFlowSearch2.Designer.vb b/GUIs.ZooFlow/Search/frmFlowSearch2.Designer.vb index ff20de53..423423f7 100644 --- a/GUIs.ZooFlow/Search/frmFlowSearch2.Designer.vb +++ b/GUIs.ZooFlow/Search/frmFlowSearch2.Designer.vb @@ -51,7 +51,7 @@ Partial Class frmFlowSearch2 Me.PanelControl1 = New DevExpress.XtraEditors.PanelControl() Me.PanelControl2 = New DevExpress.XtraEditors.PanelControl() Me.LayoutControl1 = New DevExpress.XtraLayout.LayoutControl() - Me.TokenEdit1 = New DevExpress.XtraEditors.TokenEdit() + Me.TokenEditEx1 = New DigitalData.GUIs.ZooFlow.TokenEditEx() Me.TextEdit1 = New DevExpress.XtraEditors.ButtonEdit() Me.GridControl1 = New DevExpress.XtraGrid.GridControl() Me.TileView1 = New DevExpress.XtraGrid.Views.Tile.TileView() @@ -69,9 +69,9 @@ Partial Class frmFlowSearch2 Me.LayoutControlItem4 = New DevExpress.XtraLayout.LayoutControlItem() Me.EmptySpaceItem1 = New DevExpress.XtraLayout.EmptySpaceItem() Me.LayoutControlItem6 = New DevExpress.XtraLayout.LayoutControlItem() - Me.LayoutControlItem5 = New DevExpress.XtraLayout.LayoutControlItem() Me.LayoutControlGroup3 = New DevExpress.XtraLayout.LayoutControlGroup() Me.LayoutControlItem3 = New DevExpress.XtraLayout.LayoutControlItem() + Me.LayoutControlItem5 = New DevExpress.XtraLayout.LayoutControlItem() Me.LayoutControlItem7 = New DevExpress.XtraLayout.LayoutControlItem() Me.SvgImageCollection1 = New DevExpress.Utils.SvgImageCollection(Me.components) CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit() @@ -82,7 +82,7 @@ Partial Class frmFlowSearch2 Me.PanelControl2.SuspendLayout() CType(Me.LayoutControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.LayoutControl1.SuspendLayout() - CType(Me.TokenEdit1.Properties, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.TokenEditEx1.Properties, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.TextEdit1.Properties, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.TileView1, System.ComponentModel.ISupportInitialize).BeginInit() @@ -101,9 +101,9 @@ Partial Class frmFlowSearch2 CType(Me.LayoutControlItem4, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.EmptySpaceItem1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.LayoutControlItem6, System.ComponentModel.ISupportInitialize).BeginInit() - CType(Me.LayoutControlItem5, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.LayoutControlGroup3, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.LayoutControlItem3, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.LayoutControlItem5, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.LayoutControlItem7, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.SvgImageCollection1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() @@ -228,7 +228,8 @@ Partial Class frmFlowSearch2 ' 'LayoutControl1 ' - Me.LayoutControl1.Controls.Add(Me.TokenEdit1) + Me.LayoutControl1.BackColor = System.Drawing.Color.FromArgb(CType(CType(240, Byte), Integer), CType(CType(240, Byte), Integer), CType(CType(240, Byte), Integer)) + Me.LayoutControl1.Controls.Add(Me.TokenEditEx1) Me.LayoutControl1.Controls.Add(Me.TextEdit1) Me.LayoutControl1.Controls.Add(Me.GridControl1) Me.LayoutControl1.Controls.Add(Me.RadioGroup1) @@ -245,23 +246,24 @@ Partial Class frmFlowSearch2 Me.LayoutControl1.TabIndex = 0 Me.LayoutControl1.Text = "LayoutControl1" ' - 'TokenEdit1 + 'TokenEditEx1 ' - Me.TokenEdit1.Location = New System.Drawing.Point(0, 0) - Me.TokenEdit1.Margin = New System.Windows.Forms.Padding(10) - Me.TokenEdit1.MenuManager = Me.RibbonControl1 - Me.TokenEdit1.Name = "TokenEdit1" - Me.TokenEdit1.Properties.Appearance.Font = New System.Drawing.Font("Segoe UI", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.TokenEdit1.Properties.Appearance.Options.UseFont = True - Me.TokenEdit1.Properties.NullText = "Suchbegriffe eingeben.." - Me.TokenEdit1.Properties.Separators.AddRange(New String() {","}) - Me.TokenEdit1.Size = New System.Drawing.Size(886, 36) - Me.TokenEdit1.StyleController = Me.LayoutControl1 - Me.TokenEdit1.TabIndex = 9 + Me.TokenEditEx1.Location = New System.Drawing.Point(10, 10) + Me.TokenEditEx1.MenuManager = Me.RibbonControl1 + Me.TokenEditEx1.Name = "TokenEditEx1" + Me.TokenEditEx1.Properties.Appearance.BackColor = System.Drawing.Color.White + Me.TokenEditEx1.Properties.Appearance.Font = New System.Drawing.Font("Segoe UI", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.TokenEditEx1.Properties.Appearance.Options.UseBackColor = True + Me.TokenEditEx1.Properties.Appearance.Options.UseFont = True + Me.TokenEditEx1.Properties.NullText = "Suchbegriff eingeben.." + Me.TokenEditEx1.Properties.Separators.AddRange(New String() {","}) + Me.TokenEditEx1.Size = New System.Drawing.Size(866, 36) + Me.TokenEditEx1.StyleController = Me.LayoutControl1 + Me.TokenEditEx1.TabIndex = 4 ' 'TextEdit1 ' - Me.TextEdit1.Location = New System.Drawing.Point(0, 301) + Me.TextEdit1.Location = New System.Drawing.Point(0, 284) Me.TextEdit1.MenuManager = Me.RibbonControl1 Me.TextEdit1.Name = "TextEdit1" Me.TextEdit1.Properties.Appearance.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) @@ -277,11 +279,11 @@ Partial Class frmFlowSearch2 ' 'GridControl1 ' - Me.GridControl1.Location = New System.Drawing.Point(14, 90) + Me.GridControl1.Location = New System.Drawing.Point(14, 110) Me.GridControl1.MainView = Me.TileView1 Me.GridControl1.MenuManager = Me.RibbonControl1 Me.GridControl1.Name = "GridControl1" - Me.GridControl1.Size = New System.Drawing.Size(858, 197) + Me.GridControl1.Size = New System.Drawing.Size(858, 160) Me.GridControl1.TabIndex = 1 Me.GridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.TileView1, Me.GridView1}) ' @@ -344,7 +346,7 @@ Partial Class frmFlowSearch2 ' 'RadioGroup1 ' - Me.RadioGroup1.Location = New System.Drawing.Point(4, 389) + Me.RadioGroup1.Location = New System.Drawing.Point(4, 372) Me.RadioGroup1.MenuManager = Me.RibbonControl1 Me.RadioGroup1.Name = "RadioGroup1" Me.RadioGroup1.Properties.Appearance.BackColor = System.Drawing.SystemColors.Control @@ -352,14 +354,14 @@ Partial Class frmFlowSearch2 Me.RadioGroup1.Properties.Columns = 2 Me.RadioGroup1.Properties.ItemHorzAlignment = DevExpress.XtraEditors.RadioItemHorzAlignment.Near Me.RadioGroup1.Properties.ItemsLayout = DevExpress.XtraEditors.RadioGroupItemsLayout.Flow - Me.RadioGroup1.Size = New System.Drawing.Size(615, 89) + Me.RadioGroup1.Size = New System.Drawing.Size(615, 106) Me.RadioGroup1.StyleController = Me.LayoutControl1 Me.RadioGroup1.TabIndex = 4 ' 'DateEditFrom ' Me.DateEditFrom.EditValue = Nothing - Me.DateEditFrom.Location = New System.Drawing.Point(700, 392) + Me.DateEditFrom.Location = New System.Drawing.Point(700, 375) Me.DateEditFrom.MenuManager = Me.RibbonControl1 Me.DateEditFrom.Name = "DateEditFrom" Me.DateEditFrom.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}) @@ -371,7 +373,7 @@ Partial Class frmFlowSearch2 'DateEditTo ' Me.DateEditTo.EditValue = Nothing - Me.DateEditTo.Location = New System.Drawing.Point(700, 445) + Me.DateEditTo.Location = New System.Drawing.Point(700, 428) Me.DateEditTo.MenuManager = Me.RibbonControl1 Me.DateEditTo.Name = "DateEditTo" Me.DateEditTo.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}) @@ -382,7 +384,7 @@ Partial Class frmFlowSearch2 ' 'CheckEdit1 ' - Me.CheckEdit1.Location = New System.Drawing.Point(627, 419) + Me.CheckEdit1.Location = New System.Drawing.Point(627, 402) Me.CheckEdit1.MenuManager = Me.RibbonControl1 Me.CheckEdit1.Name = "CheckEdit1" Me.CheckEdit1.Properties.OffText = "Datum bis deaktiviert" @@ -395,7 +397,7 @@ Partial Class frmFlowSearch2 ' Me.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.[True] Me.Root.GroupBordersVisible = False - Me.Root.Items.AddRange(New DevExpress.XtraLayout.BaseLayoutItem() {Me.LayoutControlGroupDate1, Me.LayoutControlGroupDate2, Me.LayoutControlGroup3, Me.LayoutControlItem7, Me.LayoutControlItem5}) + Me.Root.Items.AddRange(New DevExpress.XtraLayout.BaseLayoutItem() {Me.LayoutControlGroupDate1, Me.LayoutControlGroupDate2, Me.LayoutControlGroup3, Me.LayoutControlItem5, Me.LayoutControlItem7}) Me.Root.Name = "Root" Me.Root.Padding = New DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0) Me.Root.Size = New System.Drawing.Size(886, 482) @@ -411,10 +413,10 @@ Partial Class frmFlowSearch2 Me.LayoutControlGroupDate1.BestFitWeight = 0 Me.LayoutControlGroupDate1.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.[False] Me.LayoutControlGroupDate1.Items.AddRange(New DevExpress.XtraLayout.BaseLayoutItem() {Me.LayoutControlItem1}) - Me.LayoutControlGroupDate1.Location = New System.Drawing.Point(0, 345) + Me.LayoutControlGroupDate1.Location = New System.Drawing.Point(0, 328) Me.LayoutControlGroupDate1.Name = "LayoutControlGroupDate1" Me.LayoutControlGroupDate1.Padding = New DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0) - Me.LayoutControlGroupDate1.Size = New System.Drawing.Size(623, 137) + Me.LayoutControlGroupDate1.Size = New System.Drawing.Size(623, 154) Me.LayoutControlGroupDate1.Spacing = New DevExpress.XtraLayout.Utils.Padding(2, 2, 20, 2) Me.LayoutControlGroupDate1.Text = "Datums Einschränkung" Me.LayoutControlGroupDate1.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never @@ -424,7 +426,7 @@ Partial Class frmFlowSearch2 Me.LayoutControlItem1.Control = Me.RadioGroup1 Me.LayoutControlItem1.Location = New System.Drawing.Point(0, 0) Me.LayoutControlItem1.Name = "LayoutControlItem1" - Me.LayoutControlItem1.Size = New System.Drawing.Size(619, 93) + Me.LayoutControlItem1.Size = New System.Drawing.Size(619, 110) Me.LayoutControlItem1.TextSize = New System.Drawing.Size(0, 0) Me.LayoutControlItem1.TextVisible = False ' @@ -436,10 +438,10 @@ Partial Class frmFlowSearch2 Me.LayoutControlGroupDate2.AppearanceGroup.Options.UseBorderColor = True Me.LayoutControlGroupDate2.BestFitWeight = 0 Me.LayoutControlGroupDate2.Items.AddRange(New DevExpress.XtraLayout.BaseLayoutItem() {Me.LayoutControlItem2, Me.LayoutControlItem4, Me.EmptySpaceItem1, Me.LayoutControlItem6}) - Me.LayoutControlGroupDate2.Location = New System.Drawing.Point(623, 345) + Me.LayoutControlGroupDate2.Location = New System.Drawing.Point(623, 328) Me.LayoutControlGroupDate2.Name = "LayoutControlGroupDate2" Me.LayoutControlGroupDate2.Padding = New DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0) - Me.LayoutControlGroupDate2.Size = New System.Drawing.Size(263, 137) + Me.LayoutControlGroupDate2.Size = New System.Drawing.Size(263, 154) Me.LayoutControlGroupDate2.Spacing = New DevExpress.XtraLayout.Utils.Padding(2, 2, 20, 2) Me.LayoutControlGroupDate2.Text = "Eigenes Datum" Me.LayoutControlGroupDate2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never @@ -470,7 +472,7 @@ Partial Class frmFlowSearch2 Me.EmptySpaceItem1.AllowHotTrack = False Me.EmptySpaceItem1.Location = New System.Drawing.Point(0, 83) Me.EmptySpaceItem1.Name = "EmptySpaceItem1" - Me.EmptySpaceItem1.Size = New System.Drawing.Size(259, 10) + Me.EmptySpaceItem1.Size = New System.Drawing.Size(259, 27) Me.EmptySpaceItem1.TextSize = New System.Drawing.Size(0, 0) ' 'LayoutControlItem6 @@ -482,26 +484,14 @@ Partial Class frmFlowSearch2 Me.LayoutControlItem6.TextSize = New System.Drawing.Size(0, 0) Me.LayoutControlItem6.TextVisible = False ' - 'LayoutControlItem5 - ' - Me.LayoutControlItem5.BestFitWeight = 0 - Me.LayoutControlItem5.Control = Me.TextEdit1 - Me.LayoutControlItem5.Location = New System.Drawing.Point(0, 301) - Me.LayoutControlItem5.Name = "LayoutControlItem5" - Me.LayoutControlItem5.Padding = New DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0) - Me.LayoutControlItem5.Size = New System.Drawing.Size(886, 44) - Me.LayoutControlItem5.TextSize = New System.Drawing.Size(0, 0) - Me.LayoutControlItem5.TextVisible = False - Me.LayoutControlItem5.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never - ' 'LayoutControlGroup3 ' Me.LayoutControlGroup3.AppearanceGroup.BorderColor = System.Drawing.Color.FromArgb(CType(CType(165, Byte), Integer), CType(CType(36, Byte), Integer), CType(CType(19, Byte), Integer)) Me.LayoutControlGroup3.AppearanceGroup.Options.UseBorderColor = True Me.LayoutControlGroup3.Items.AddRange(New DevExpress.XtraLayout.BaseLayoutItem() {Me.LayoutControlItem3}) - Me.LayoutControlGroup3.Location = New System.Drawing.Point(0, 36) + Me.LayoutControlGroup3.Location = New System.Drawing.Point(0, 56) Me.LayoutControlGroup3.Name = "LayoutControlGroup3" - Me.LayoutControlGroup3.Size = New System.Drawing.Size(886, 265) + Me.LayoutControlGroup3.Size = New System.Drawing.Size(886, 228) Me.LayoutControlGroup3.Spacing = New DevExpress.XtraLayout.Utils.Padding(2, 2, 20, 2) Me.LayoutControlGroup3.Text = "Meine Suchen" ' @@ -510,17 +500,29 @@ Partial Class frmFlowSearch2 Me.LayoutControlItem3.Control = Me.GridControl1 Me.LayoutControlItem3.Location = New System.Drawing.Point(0, 0) Me.LayoutControlItem3.Name = "LayoutControlItem3" - Me.LayoutControlItem3.Size = New System.Drawing.Size(862, 201) + Me.LayoutControlItem3.Size = New System.Drawing.Size(862, 164) Me.LayoutControlItem3.TextSize = New System.Drawing.Size(0, 0) Me.LayoutControlItem3.TextVisible = False ' + 'LayoutControlItem5 + ' + Me.LayoutControlItem5.BestFitWeight = 0 + Me.LayoutControlItem5.Control = Me.TextEdit1 + Me.LayoutControlItem5.Location = New System.Drawing.Point(0, 284) + Me.LayoutControlItem5.Name = "LayoutControlItem5" + Me.LayoutControlItem5.Padding = New DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0) + Me.LayoutControlItem5.Size = New System.Drawing.Size(886, 44) + Me.LayoutControlItem5.TextSize = New System.Drawing.Size(0, 0) + Me.LayoutControlItem5.TextVisible = False + Me.LayoutControlItem5.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never + ' 'LayoutControlItem7 ' - Me.LayoutControlItem7.Control = Me.TokenEdit1 + Me.LayoutControlItem7.Control = Me.TokenEditEx1 Me.LayoutControlItem7.Location = New System.Drawing.Point(0, 0) Me.LayoutControlItem7.Name = "LayoutControlItem7" - Me.LayoutControlItem7.Padding = New DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0) - Me.LayoutControlItem7.Size = New System.Drawing.Size(886, 36) + Me.LayoutControlItem7.Padding = New DevExpress.XtraLayout.Utils.Padding(10, 10, 10, 10) + Me.LayoutControlItem7.Size = New System.Drawing.Size(886, 56) Me.LayoutControlItem7.TextSize = New System.Drawing.Size(0, 0) Me.LayoutControlItem7.TextVisible = False ' @@ -551,7 +553,7 @@ Partial Class frmFlowSearch2 Me.PanelControl2.ResumeLayout(False) CType(Me.LayoutControl1, System.ComponentModel.ISupportInitialize).EndInit() Me.LayoutControl1.ResumeLayout(False) - CType(Me.TokenEdit1.Properties, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.TokenEditEx1.Properties, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.TextEdit1.Properties, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.TileView1, System.ComponentModel.ISupportInitialize).EndInit() @@ -570,9 +572,9 @@ Partial Class frmFlowSearch2 CType(Me.LayoutControlItem4, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.EmptySpaceItem1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.LayoutControlItem6, System.ComponentModel.ISupportInitialize).EndInit() - CType(Me.LayoutControlItem5, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.LayoutControlGroup3, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.LayoutControlItem3, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.LayoutControlItem5, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.LayoutControlItem7, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.SvgImageCollection1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) @@ -617,6 +619,6 @@ Partial Class frmFlowSearch2 Friend WithEvents RepositoryItemMarqueeProgressBar1 As DevExpress.XtraEditors.Repository.RepositoryItemMarqueeProgressBar Friend WithEvents SvgImageCollection1 As DevExpress.Utils.SvgImageCollection Friend WithEvents colImage As DevExpress.XtraGrid.Columns.TileViewColumn - Friend WithEvents TokenEdit1 As DevExpress.XtraEditors.TokenEdit + Friend WithEvents TokenEditEx1 As TokenEditEx Friend WithEvents LayoutControlItem7 As DevExpress.XtraLayout.LayoutControlItem End Class diff --git a/GUIs.ZooFlow/Search/frmFlowSearch2.vb b/GUIs.ZooFlow/Search/frmFlowSearch2.vb index aca4e251..571de6d5 100644 --- a/GUIs.ZooFlow/Search/frmFlowSearch2.vb +++ b/GUIs.ZooFlow/Search/frmFlowSearch2.vb @@ -8,34 +8,30 @@ Imports DevExpress.XtraSplashScreen Imports DigitalData.GUIs.ZooFlow.ClassConstants Imports DigitalData.GUIs.ZooFlow.Search Imports DigitalData.GUIs.ZooFlow.Search.SearchToken +Imports DigitalData.Modules.Language Imports DigitalData.Modules.Logging Public Class frmFlowSearch2 Private ReadOnly LogConfig As LogConfig = My.LogConfig Private ReadOnly Logger = My.LogConfig.GetLogger() Private SearchRunner As SearchRunner - Private Search As Search.Search Private TokenListDefault As New Dictionary(Of String, Object) Private TokenListOperands As New Dictionary(Of String, Object) Private TokenListAttrValues As New Dictionary(Of String, Object) Private Sub frmFlowSearch2_Load(sender As Object, e As EventArgs) Handles MyBase.Load - Search = New Search.Search(LogConfig, My.Application.User, My.Database) SearchRunner = New SearchRunner(My.LogConfig, My.Application.GetEnvironment, "FlowSearch") With { .BaseSearchSQL = LoadBaseSQL() } - TextEdit1.MaskBox.AutoCompleteSource = AutoCompleteSource.CustomSource - TextEdit1.MaskBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend - TextEdit1.MaskBox.AutoCompleteCustomSource = LoadAutoSuggest() RadioGroup1.Properties.Items.AddRange(LoadDateConstraints.ToArray) GridControl1.DataSource = LoadPredefinedSearches() - Dim oTokens = Search.GetValueTokensForAttribute() - AddTokens(TokenEdit1, oTokens) + Dim oTokens = GetValueTokensForAttribute() + AddTokens(TokenEditEx1, oTokens) End Sub Private Function LoadBaseSQL() As String @@ -52,21 +48,26 @@ Public Class frmFlowSearch2 Return oSQL End Function - Private Function LoadAutoSuggest() As AutoCompleteStringCollection - Dim oCollection As New AutoCompleteStringCollection - Dim oSql = $"EXEC PRIDB_SEARCH_AUTOSUGGEST '{My.Application.User.Language}',{My.Application.User.UserId}" - Dim oTable As DataTable = My.Database.GetDatatableIDB(oSql) - - If oTable Is Nothing Then - - Return New AutoCompleteStringCollection() - End If + Public Function GetValueTokensForAttribute() As List(Of AttributeValueToken) + Dim oSQL = $"EXEC PRIDB_SEARCH_AUTOSUGGEST '{My.Application.User.Language}', {My.Application.User.UserId}" + Dim oTable = My.Database.GetDatatableIDB(oSQL) + Dim oTokens As New List(Of AttributeValueToken) For Each oRow As DataRow In oTable.Rows - oCollection.Add(oRow.Item("TERM")) + Dim oTermValue = oRow.Item("TERM") + Dim oTermId = oRow.ItemEx("TERM_ID", 0) + Dim oAttributeTitle = oRow.Item("ATTR_TITLE") + Dim oAttributeId = oRow.ItemEx("ATTR_ID", 0) + + oTokens.Add(New AttributeValueToken() With { + .AttributeId = oAttributeId, + .AttributeTitle = oAttributeTitle, + .TermId = oTermId, + .TermValue = oTermValue + }) Next - Return oCollection + Return oTokens.Distinct().ToList() End Function Private Function LoadDateConstraints() As List(Of RadioGroupItem) @@ -117,36 +118,39 @@ Public Class frmFlowSearch2 } End Function + Private Function GetTokens() As IEnumerable(Of AttributeValueToken) + Dim oTokens = TokenEditEx1.GetTokenList() + Return oTokens.Select(Of AttributeValueToken)(Function(token) token.Value) + End Function + Private Async Sub TextEdit1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextEdit1.KeyUp If e.KeyCode = Keys.Enter Then - Await RunSearch(TextEdit1.EditValue) + Dim oTokens = GetTokens() + Await RunSearch(oTokens) End If End Sub - Private Async Sub SearchControl2_KeyUp(sender As Object, e As KeyEventArgs) Handles TokenEdit1.KeyUp - If e.KeyCode = Keys.Enter And TokenEdit1.IsPopupOpen = False Then - Dim oTokens = TokenEdit1.GetTokenList() - Dim oFirstToken = oTokens.FirstOrDefault() - - If oFirstToken Is Nothing Then - Exit Sub - End If - - Dim oTokenValue As TokenValue = oFirstToken.Value - - Await RunSearch(oTokenValue.Value) + Private Async Sub SearchControl2_KeyUp(sender As Object, e As KeyEventArgs) Handles TokenEditEx1.KeyUp + If e.KeyCode = Keys.Enter And TokenEditEx1.IsPopupOpen = False Then + Dim oTokens = GetTokens() + Await RunSearch(oTokens) End If End Sub Private Async Sub TextEdit1_ButtonClick(sender As Object, e As DevExpress.XtraEditors.Controls.ButtonPressedEventArgs) Handles TextEdit1.ButtonClick If e.Button.Tag = "SEARCH" Then - Await RunSearch(TextEdit1.EditValue) + Dim oTokens = GetTokens() + Await RunSearch(oTokens) End If End Sub - Private Async Function RunSearch(pSearchTerm As String) As Threading.Tasks.Task + Private Async Function RunSearch(pTokens As IEnumerable(Of AttributeValueToken)) As Threading.Tasks.Task Dim oHandle = StartUpdateUI() + If pTokens.Count = 0 Then + Exit Function + End If + Try Dim oDateFrom = DateEditFrom.EditValue Dim oDateTo = DateEditTo.EditValue @@ -156,7 +160,7 @@ Public Class frmFlowSearch2 End If SearchRunner.SetDateConstraint() - Dim oResult = Await SearchRunner.RunWithSearchTerm(pSearchTerm, oDateFrom, oDateTo) + Dim oResult = Await SearchRunner.RunWithSearchTerm(String.Empty, oDateFrom, oDateTo, pTokens, "") If oResult.OK = False Then SetStatusBarColor(Color.OrangeRed) @@ -280,70 +284,17 @@ Public Class frmFlowSearch2 AddTokens(Editor, Tokens) End Sub - Private Sub AddTokens(Editor As TokenEdit, Tokens As Dictionary(Of String, Object)) + Private Sub AddTokens(Editor As TokenEdit, Tokens As IEnumerable(Of AttributeValueToken)) For Each oToken In Tokens Dim oTokenEditToken = New TokenEditToken With { - .Description = oToken.Key, - .Value = oToken.Value + .Description = oToken.ToString, + .Value = oToken } Editor.Properties.Tokens.Add(oTokenEditToken) Next End Sub - 'Private Sub SearchControl2_Properties_TokenAdded(sender As Object, e As DevExpress.XtraEditors.TokenEditTokenAddedEventArgs) Handles TokenEdit1.Properties.TokenAdded - ' Dim oEditor As TokenEdit = sender - ' SetNewTokens(oEditor) - 'End Sub - - 'Private Sub SearchControl2_Properties_TokenRemoved(sender As Object, e As TokenEditTokenRemovedEventArgs) Handles TokenEdit1.Properties.TokenRemoved - ' Dim oEditor As TokenEdit = sender - ' SetNewTokens(oEditor) - 'End Sub - - Private Sub SetNewTokens(pEditor As TokenEdit) - Dim oLastToken = pEditor.GetTokenList().LastOrDefault() - pEditor.Properties.BeginUpdate() - - If pEditor.GetTokenList().Count > 0 Then - SetTokens(pEditor, TokenListDefault) - Search.InputMode = InputMode.Default - Else - SetTokens(pEditor, New Dictionary(Of String, Object)) - Search.InputMode = InputMode.Default - End If - - 'If oLastToken IsNot Nothing Then - ' Select Case oLastToken.Value.GetType - - ' Case GetType(AttributeKeyToken) - ' ' After the attribute key comes an operator - ' SetTokens(pEditor, Search.GetOperatorTokens(GetType(String))) - ' Search.InputMode = InputMode.Operator - - ' Case GetType(AttributeOperatorToken) - ' ' After the attribute operator comes a value - ' SetTokens(pEditor, TokenListAttrValues) - ' Search.InputMode = InputMode.Value - - ' Case GetType(AttributeValueToken) - ' ' After the attribute value comes another value - ' SetTokens(pEditor, TokenListAttrValues) - ' Search.InputMode = InputMode.Value - - ' Case Else - ' SetTokens(pEditor, TokenListDefault) - ' Search.InputMode = InputMode.Default - - ' End Select - 'Else - ' SetTokens(pEditor, TokenListDefault) - ' Search.InputMode = InputMode.Default - 'End If - - pEditor.Properties.EndUpdate() - End Sub - - Private Sub SearchControl2_CustomDrawTokenGlyph(sender As Object, e As TokenEditCustomDrawTokenGlyphEventArgs) Handles TokenEdit1.CustomDrawTokenGlyph + Private Sub SearchControl2_CustomDrawTokenGlyph(sender As Object, e As TokenEditCustomDrawTokenGlyphEventArgs) Handles TokenEditEx1.CustomDrawTokenGlyph ' Set Background according to token type Select Case e.Value.GetType() Case GetType(AttributeValueToken) @@ -355,6 +306,4 @@ Public Class frmFlowSearch2 ' This fixes: https://supportcenter.devexpress.com/ticket/details/t215578/tokenedit-glyph-is-not-visible-when-customdrawtokentext-is-used e.DefaultDraw() End Sub - - End Class \ No newline at end of file diff --git a/GUIs.ZooFlow/Search/frmFlowSearch2/TokenEditEx.vb b/GUIs.ZooFlow/Search/frmFlowSearch2/TokenEditEx.vb new file mode 100644 index 00000000..5dcfc3cd --- /dev/null +++ b/GUIs.ZooFlow/Search/frmFlowSearch2/TokenEditEx.vb @@ -0,0 +1,75 @@ +Imports System.ComponentModel +Imports DevExpress.XtraEditors +Imports DevExpress.XtraEditors.Drawing +Imports DevExpress.XtraEditors.Registrator +Imports DevExpress.XtraEditors.Repository +Imports DevExpress.XtraEditors.ViewInfo + +Public Class RepositoryItemTokenEditEx + Inherits RepositoryItemTokenEdit + + ' The unique name for the custom editor + Public Const CustomEditName As String = "TokenEditEx" + + Shared Sub New() + RegisterTokenEditEx() + End Sub + + ' Return the unique name + Public Overrides ReadOnly Property EditorTypeName() As String + Get + Return CustomEditName + End Get + End Property + + Public Shared Sub RegisterTokenEditEx() + EditorRegistrationInfo.Default.Editors.Add( + New EditorClassInfo(CustomEditName, + GetType(TokenEditEx), + GetType(RepositoryItemTokenEditEx), + GetType(TokenEditViewInfoEx), + New TokenEditPainter, + True)) + End Sub +End Class + +Public Class TokenEditViewInfoEx + Inherits TokenEditViewInfo + + Public Sub New(item As RepositoryItem) + MyBase.New(item) + End Sub + + Protected Overrides Function CalcItemSizeCore(token As TokenEditToken) As Size + Dim oSize = MyBase.CalcItemSizeCore(token) + oSize.Width += 15 + Return oSize + End Function +End Class + + + +Public Class TokenEditEx + Inherits TokenEdit + + Shared Sub New() + RepositoryItemTokenEditEx.RegisterTokenEditEx() + End Sub + + Public Sub New() + + End Sub + + Public Overrides ReadOnly Property EditorTypeName() As String + Get + Return RepositoryItemTokenEditEx.CustomEditName + End Get + End Property + + + Public Shadows ReadOnly Property Properties As RepositoryItemTokenEditEx + Get + Return TryCast(MyBase.Properties, RepositoryItemTokenEditEx) + End Get + End Property +End Class diff --git a/GUIs.ZooFlow/ZooFlow.vbproj b/GUIs.ZooFlow/ZooFlow.vbproj index b744f81f..1b54dba1 100644 --- a/GUIs.ZooFlow/ZooFlow.vbproj +++ b/GUIs.ZooFlow/ZooFlow.vbproj @@ -351,6 +351,9 @@ MyDataset.xsd + + Component + frmFlowSearch.vb @@ -455,7 +458,6 @@ -