fix Chat
This commit is contained in:
@@ -7,6 +7,8 @@ Public Class ChatControl
|
||||
Private ReadOnly IdentificationColumn As String = "USER_FROM"
|
||||
Private ReadOnly MessageColumn As String = "MESSAGE_TEXT"
|
||||
Private ReadOnly DateColumn As String = "ADDED_WHEN"
|
||||
Private ReadOnly ToUserColumn As String = "TO_USER"
|
||||
|
||||
Public Delegate Sub ConversationEnded()
|
||||
Public Event Conversation_Ended As ConversationEnded
|
||||
Public Delegate Sub ConversationUsersAdded_Success()
|
||||
@@ -158,7 +160,10 @@ Public Class ChatControl
|
||||
' BuildUsernameColorDict(oDatatable)
|
||||
oSQL = $"SELECT * FROM VWIDB_CONVERSATION WHERE CONVERSATION_ID = {ConversationId}"
|
||||
Dim oDatatable2 As DataTable = Db.GetDatatable(oSQL)
|
||||
|
||||
GridChatOld.DataSource = ChatSource
|
||||
GridChat.DataSource = ChatSource
|
||||
|
||||
ChatSource.DataSource = oDatatable
|
||||
tsmitmTitle.Text = oDatatable2.Rows(0).Item("TITLE")
|
||||
CurrentConversationID = ConversationId
|
||||
@@ -215,6 +220,7 @@ Public Class ChatControl
|
||||
Dim oResult = Db.GetScalarValue(oSQL)
|
||||
LoadConversation(CurrentConversationID)
|
||||
RichTextBox1.Text = String.Empty
|
||||
ChatViewOld.MoveLast()
|
||||
ChatView.MoveLast()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
@@ -235,44 +241,38 @@ Public Class ChatControl
|
||||
' End Sub)
|
||||
'End Sub
|
||||
|
||||
Private Sub ChatView_CustomItemTemplate(sender As Object, e As TileViewCustomItemTemplateEventArgs) Handles ChatView.CustomItemTemplate
|
||||
Dim oRow As DataRow = ChatView.GetDataRow(e.RowHandle)
|
||||
Private Sub ChatView_CustomItemTemplate(sender As Object, e As TileViewCustomItemTemplateEventArgs) Handles ChatViewOld.CustomItemTemplate
|
||||
Dim oRow As DataRow = ChatViewOld.GetDataRow(e.RowHandle)
|
||||
Dim oIdentification As String = oRow.Item(IdentificationColumn)
|
||||
Dim oToUser = oRow.Item("TO_USER")
|
||||
Dim oToUser = oRow.Item(ToUserColumn)
|
||||
|
||||
If Not IsDBNull(oToUser) Then
|
||||
e.Template = e.Templates.Item("ChatTo")
|
||||
Else
|
||||
If oIdentification = ConversationIdentification Or oIdentification = Username Then
|
||||
e.Template = e.Templates.Item("ChatRight")
|
||||
Else
|
||||
e.Template = e.Templates.Item("ChatLeft")
|
||||
End If
|
||||
'If oIdentification = ConversationIdentification Or oIdentification = Username Then
|
||||
' e.Template = e.Templates.Item("ChatRight")
|
||||
'Else
|
||||
' e.Template = e.Templates.Item("ChatLeft")
|
||||
'End If
|
||||
e.Template = e.Templates.Item("ChatLeft")
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ChatView_ItemCustomize(sender As Object, e As TileViewItemCustomizeEventArgs) Handles ChatView.ItemCustomize
|
||||
Dim oRow As DataRow = ChatView.GetDataRow(e.RowHandle)
|
||||
|
||||
Private Sub ChatView_ItemCustomize(sender As Object, e As TileViewItemCustomizeEventArgs) Handles ChatViewOld.ItemCustomize
|
||||
Dim oRow As DataRow = ChatViewOld.GetDataRow(e.RowHandle)
|
||||
Dim oUsername As String = oRow.Item(IdentificationColumn)
|
||||
Dim oMessage As String = oRow.Item(MessageColumn)
|
||||
Dim oToUser = oRow.Item(ToUserColumn)
|
||||
' Dim oColor As Color = UsernameColorsDict.Item(oUsername)
|
||||
|
||||
If oUsername = ConversationIdentification Or oUsername = Username Then
|
||||
e.Item.AppearanceItem.Normal.BackColor = Color.PaleTurquoise
|
||||
e.Item.Item(IdentificationColumn).Appearance.Normal.ForeColor = Color.Purple
|
||||
Else
|
||||
' e.Item.AppearanceItem.Normal.BackColor = Color.whi
|
||||
e.Item.Item(IdentificationColumn).Appearance.Normal.ForeColor = Color.Red
|
||||
End If
|
||||
'e.Item.AppearanceItem.Focused.BackColor = Color.Turquoise
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub txtMessage_KeyUp(sender As Object, e As KeyEventArgs)
|
||||
|
||||
e.Item.ItemSize = DevExpress.XtraEditors.TileItemSize.Wide
|
||||
End Sub
|
||||
|
||||
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles btnSendMessage.Click
|
||||
@@ -281,18 +281,6 @@ Public Class ChatControl
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub TextBox1_KeyUp(sender As Object, e As KeyEventArgs)
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ChatControl_Click(sender As Object, e As EventArgs) Handles MyBase.Click
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ChatControl_Leave(sender As Object, e As EventArgs) Handles Me.Leave
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ToolStripMenuItemConv_end_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItemConv_end.Click
|
||||
If CurrentConversationID <> 0 Then
|
||||
Dim result As MsgBoxResult
|
||||
@@ -342,14 +330,9 @@ Public Class ChatControl
|
||||
If e.Control And e.KeyCode = Keys.Enter And RichTextBox1.Text.Count > 0 Then
|
||||
NewMessage(RichTextBox1.Text)
|
||||
ElseIf (Keys.Alt AndAlso Keys.Control) And e.KeyCode = keys.Q Then
|
||||
|
||||
|
||||
With RichTextBox1
|
||||
ListBoxUserMention.Left = .GetPositionFromCharIndex(
|
||||
.SelectionStart).X + .Left + 10
|
||||
ListBoxUserMention.Top = .GetPositionFromCharIndex(
|
||||
.SelectionStart).Y + .Top + 20
|
||||
|
||||
ListBoxUserMention.Left = .GetPositionFromCharIndex(.SelectionStart).X + .Left + 10
|
||||
ListBoxUserMention.Top = .GetPositionFromCharIndex(.SelectionStart).Y + .Top + 20
|
||||
' Jetzt ListBox einblendenden, Focus auf diese setzen
|
||||
' und den ersten Eintrag selektieren
|
||||
ListBoxUserMention.Visible = True
|
||||
@@ -357,7 +340,6 @@ Public Class ChatControl
|
||||
ListBoxUserMention.SelectedIndex = 0
|
||||
End With
|
||||
|
||||
|
||||
'Dim opoint As Point = GetPoint(sender)
|
||||
'AssistListBox.PointToClient(opoint)
|
||||
'pnlMessage.Controls.Add(AssistListBox)
|
||||
@@ -365,9 +347,7 @@ Public Class ChatControl
|
||||
'AssistListBox.BringToFront()
|
||||
|
||||
' '@ was pressed
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Sub AssistListBox_Changed()
|
||||
Try
|
||||
@@ -444,4 +424,56 @@ Public Class ChatControl
|
||||
End With
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ChatView_CustomDrawRowPreview(sender As Object, e As DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs) Handles ChatView.CustomDrawRowPreview
|
||||
Dim oRow As DataRow = ChatViewOld.GetDataRow(e.RowHandle)
|
||||
Dim oUsername As String = oRow.Item(IdentificationColumn)
|
||||
Dim oToUser = oRow.Item(ToUserColumn)
|
||||
Dim oIsOwnMessage As Boolean = oUsername = ConversationIdentification Or oUsername = Username
|
||||
|
||||
' Eigene Nachrichten
|
||||
If oIsOwnMessage Then
|
||||
e.Appearance.BackColor = Color.PaleTurquoise
|
||||
End If
|
||||
|
||||
' Andere Nachrichten
|
||||
If Not oIsOwnMessage Then
|
||||
e.Appearance.BackColor = Color.White
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ChatView_CustomDrawCell(sender As Object, e As DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs) Handles ChatView.CustomDrawCell
|
||||
Dim oRow As DataRow = ChatViewOld.GetDataRow(e.RowHandle)
|
||||
Dim oUsername As String = oRow.Item(IdentificationColumn)
|
||||
Dim oToUser = oRow.Item(ToUserColumn)
|
||||
|
||||
Dim oIsOwnMessage As Boolean = oUsername = ConversationIdentification Or oUsername = Username
|
||||
|
||||
' Eigene Nachrichten
|
||||
If oIsOwnMessage Then
|
||||
' Benutzername
|
||||
If e.Column.FieldName = IdentificationColumn Then
|
||||
e.Appearance.ForeColor = Color.Purple
|
||||
End If
|
||||
|
||||
e.Appearance.BackColor = Color.PaleTurquoise
|
||||
End If
|
||||
|
||||
' Andere Nachrichten
|
||||
If Not oIsOwnMessage Then
|
||||
If e.Column.FieldName = IdentificationColumn Then
|
||||
e.Appearance.ForeColor = Color.Red
|
||||
End If
|
||||
|
||||
If Not (IsNothing(oToUser) Or IsDBNull(oToUser)) Then
|
||||
If oToUser = Username Or oToUser = ConversationIdentification Then
|
||||
e.Appearance.BackColor = Color.LightSalmon
|
||||
Else
|
||||
e.Appearance.BackColor = Color.White
|
||||
End If
|
||||
Else
|
||||
e.Appearance.BackColor = Color.White
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user