Verag TV App
This commit is contained in:
@@ -14,6 +14,7 @@ Public Class frmEintragTvNew
|
||||
|
||||
Public Sub New()
|
||||
InitializeComponent()
|
||||
InitializeFontComboBoxes()
|
||||
Icon = cMeineFunktionenAVISO.GetProgrammIcon()
|
||||
End Sub
|
||||
|
||||
@@ -90,7 +91,7 @@ Public Class frmEintragTvNew
|
||||
dgvAVISOTV.DataSource = gefilterteListe
|
||||
dgvAVISOTV.Columns("TvTextBezeichnungID").HeaderText = "ID"
|
||||
dgvAVISOTV.Columns("TvTextBezeichnung").HeaderText = "Bezeichnung"
|
||||
dgvAVISOTV.Columns("FixeZeile1").HeaderText = "Zeile 1"
|
||||
dgvAVISOTV.Columns("FixeZeile1RTF").HeaderText = "Zeile 1"
|
||||
dgvAVISOTV.Columns("FixeZeile2").HeaderText = "Zeile 2"
|
||||
dgvAVISOTV.Columns("FixeZeile3").HeaderText = "Zeile 3"
|
||||
dgvAVISOTV.Columns("Standort").Visible = False
|
||||
@@ -185,40 +186,7 @@ Public Class frmEintragTvNew
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Private Sub LadeTvTextBezeichnungen()
|
||||
isInitializing = True
|
||||
Dim bezeichnungen As New List(Of cTvTextBezeichnung)()
|
||||
|
||||
Try
|
||||
bezeichnungen = AvisoTvNewDAL.LadenAlleTvTextBezeichnungen()
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Fehler beim Laden der TvTextBezeichnungen: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
isInitializing = False
|
||||
Return
|
||||
End Try
|
||||
|
||||
Dim items As New List(Of ComboBoxItem)()
|
||||
|
||||
For Each bezeichnung In bezeichnungen
|
||||
items.Add(New ComboBoxItem() With {
|
||||
.ID = bezeichnung.TvTextBezeichnungID,
|
||||
.DisplayText = bezeichnung.TvTextBezeichnung
|
||||
})
|
||||
Next
|
||||
|
||||
cmbTvTextBezeichnungAuswahl.DataSource = items
|
||||
cmbTvTextBezeichnungAuswahl.DisplayMember = "DisplayText"
|
||||
cmbTvTextBezeichnungAuswahl.ValueMember = "ID"
|
||||
cmbTvTextBezeichnungAuswahl.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
||||
cmbTvTextBezeichnungAuswahl.SelectedIndex = -1
|
||||
cmbPosition.SelectedIndex = -1
|
||||
isInitializing = False
|
||||
|
||||
Debug.WriteLine("TvTextBezeichnungen geladen:")
|
||||
For Each item In items
|
||||
Debug.WriteLine($"ID: {item.ID}, Text: {item.DisplayText}")
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub cmbTvTextBezeichnungAuswahl_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbTvTextBezeichnungAuswahl.SelectedIndexChanged
|
||||
If isInitializing Then
|
||||
@@ -259,10 +227,10 @@ Public Class frmEintragTvNew
|
||||
Else
|
||||
Debug.WriteLine("Kein bestehender Eintrag gefunden. Neuer Eintrag wird erstellt.")
|
||||
myAvisoTvNew = New cAvisoTvNew() With {
|
||||
.IsActive = True,
|
||||
.StandortID = currentStandortID,
|
||||
.Standort = currentStandort
|
||||
}
|
||||
.IsActive = True,
|
||||
.StandortID = currentStandortID,
|
||||
.Standort = currentStandort
|
||||
}
|
||||
Neuanlage = True
|
||||
Me.Text = "Neuen Eintrag hinzufügen"
|
||||
End If
|
||||
@@ -273,6 +241,148 @@ Public Class frmEintragTvNew
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub InitializeFontComboBoxes()
|
||||
Dim fontFamilies As New List(Of String)()
|
||||
For Each font As FontFamily In FontFamily.Families
|
||||
fontFamilies.Add(font.Name)
|
||||
Next
|
||||
cmbFontFamily.DataSource = fontFamilies
|
||||
cmbFontFamily.SelectedItem = rtbZeile1.Font.FontFamily.Name
|
||||
|
||||
Dim sizes As Integer() = {8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72}
|
||||
cmbFontSize.DataSource = sizes.Select(Function(s) s.ToString()).ToList()
|
||||
cmbFontSize.SelectedItem = CInt(rtbZeile1.Font.Size).ToString()
|
||||
|
||||
AddHandler cmbFontFamily.SelectedIndexChanged, AddressOf cmbFontFamily_SelectedIndexChanged
|
||||
AddHandler cmbFontSize.SelectedIndexChanged, AddressOf cmbFontSize_SelectedIndexChanged
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
' Schriftfamilie ComboBox SelectionChanged
|
||||
Private Sub cmbFontFamily_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
UpdateFont()
|
||||
End Sub
|
||||
|
||||
' Schriftgröße ComboBox SelectionChanged
|
||||
Private Sub cmbFontSize_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
UpdateFont()
|
||||
End Sub
|
||||
Private Sub UpdateFont()
|
||||
Dim selectedFontFamily As String = If(cmbFontFamily.SelectedItem, rtbZeile1.Font.FontFamily.Name)
|
||||
Dim selectedFontSize As Single
|
||||
If Single.TryParse(cmbFontSize.SelectedItem, selectedFontSize) Then
|
||||
rtbZeile1.Font = New Font(selectedFontFamily, selectedFontSize, rtbZeile1.Font.Style)
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Methode zum Umschalten des Schriftstils
|
||||
Private Sub ToggleFontStyle(style As FontStyle)
|
||||
If rtbZeile1.SelectionFont IsNot Nothing Then
|
||||
Dim currentFont As Font = rtbZeile1.SelectionFont
|
||||
Dim newFontStyle As FontStyle
|
||||
|
||||
If rtbZeile1.SelectionFont.Style.HasFlag(style) Then
|
||||
' Entferne den Stil
|
||||
newFontStyle = currentFont.Style And Not style
|
||||
Else
|
||||
' Füge den Stil hinzu
|
||||
newFontStyle = currentFont.Style Or style
|
||||
End If
|
||||
|
||||
' Setze die neue Schriftart
|
||||
rtbZeile1.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, newFontStyle)
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Fett (Bold) Button Click
|
||||
Private Sub btnBold_Click(sender As Object, e As EventArgs) Handles btnBold.Click
|
||||
ToggleFontStyle(FontStyle.Bold)
|
||||
End Sub
|
||||
|
||||
' Kursiv (Italic) Button Click
|
||||
Private Sub btnItalic_Click(sender As Object, e As EventArgs) Handles btnItalic.Click
|
||||
ToggleFontStyle(FontStyle.Italic)
|
||||
End Sub
|
||||
|
||||
' Unterstrichen (Underline) Button Click
|
||||
Private Sub btnUnderline_Click(sender As Object, e As EventArgs) Handles btnUnderline.Click
|
||||
ToggleFontStyle(FontStyle.Underline)
|
||||
End Sub
|
||||
|
||||
' Textfarbe ändern Button Click
|
||||
Private Sub btnTextColor_Click(sender As Object, e As EventArgs) Handles btnTextColor.Click
|
||||
If colorDialogText.ShowDialog() = DialogResult.OK Then
|
||||
rtbZeile1.SelectionColor = colorDialogText.Color
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Hintergrundfarbe ändern Button Click
|
||||
Private Sub btnBackColor_Click(sender As Object, e As EventArgs) Handles btnBackColor.Click
|
||||
If colorDialogText.ShowDialog() = DialogResult.OK Then
|
||||
rtbZeile1.SelectionBackColor = colorDialogText.Color
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Links ausrichten Button Click
|
||||
Private Sub btnAlignLeft_Click(sender As Object, e As EventArgs) Handles btnAlignLeft.Click
|
||||
rtbZeile1.SelectionAlignment = HorizontalAlignment.Left
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
' Mitte ausrichten Button Click
|
||||
Private Sub btnAlignCenter_Click(sender As Object, e As EventArgs) Handles btnAlignCenter.Click
|
||||
rtbZeile1.SelectionAlignment = HorizontalAlignment.Center
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
' Rechts ausrichten Button Click
|
||||
Private Sub btnAlignRight_Click(sender As Object, e As EventArgs) Handles btnAlignRight.Click
|
||||
rtbZeile1.SelectionAlignment = HorizontalAlignment.Right
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
Private Sub LadeTvTextBezeichnungen()
|
||||
isInitializing = True
|
||||
Dim bezeichnungen As New List(Of cTvTextBezeichnung)()
|
||||
|
||||
Try
|
||||
bezeichnungen = AvisoTvNewDAL.LadenAlleTvTextBezeichnungen()
|
||||
Catch ex As Exception
|
||||
MessageBox.Show("Fehler beim Laden der TvTextBezeichnungen: " & ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
isInitializing = False
|
||||
Return
|
||||
End Try
|
||||
|
||||
Dim items As New List(Of ComboBoxItem)()
|
||||
|
||||
For Each bezeichnung In bezeichnungen
|
||||
items.Add(New ComboBoxItem() With {
|
||||
.ID = bezeichnung.TvTextBezeichnungID,
|
||||
.DisplayText = bezeichnung.TvTextBezeichnung
|
||||
})
|
||||
Next
|
||||
|
||||
cmbTvTextBezeichnungAuswahl.DataSource = items
|
||||
cmbTvTextBezeichnungAuswahl.DisplayMember = "DisplayText"
|
||||
cmbTvTextBezeichnungAuswahl.ValueMember = "ID"
|
||||
cmbTvTextBezeichnungAuswahl.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
|
||||
cmbTvTextBezeichnungAuswahl.SelectedIndex = -1
|
||||
cmbPosition.SelectedIndex = -1
|
||||
isInitializing = False
|
||||
|
||||
Debug.WriteLine("TvTextBezeichnungen geladen:")
|
||||
For Each item In items
|
||||
Debug.WriteLine($"ID: {item.ID}, Text: {item.DisplayText}")
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub txtNeueTvTextBezeichnung_TextChanged(sender As Object, e As EventArgs) Handles txtNeueTvTextBezeichnung.TextChanged
|
||||
If Not String.IsNullOrWhiteSpace(txtNeueTvTextBezeichnung.Text) Then
|
||||
cmbTvTextBezeichnungAuswahl.SelectedIndex = -1
|
||||
@@ -295,7 +405,8 @@ Public Class frmEintragTvNew
|
||||
|
||||
txtNeueTvTextBezeichnung.Text = ""
|
||||
|
||||
txtZeile1.Text = aviso.FixeZeile1
|
||||
' Hier setzt du die Textzeilen, wenn vorhanden
|
||||
rtbZeile1.Rtf = aviso.FixeZeile1RTF
|
||||
txtZeile2.Text = aviso.FixeZeile2
|
||||
txtZeile3.Text = aviso.FixeZeile3
|
||||
|
||||
@@ -343,9 +454,116 @@ Public Class frmEintragTvNew
|
||||
|
||||
chkIsActive.Checked = aviso.IsActive
|
||||
|
||||
' Text-Einstellungen anwenden
|
||||
cmbFontFamily.SelectedItem = aviso.FontFamily
|
||||
cmbFontSize.SelectedItem = aviso.FontSize.ToString()
|
||||
rtbZeile1.SelectionFont = New Font(aviso.FontFamily, aviso.FontSize, CType([Enum].Parse(GetType(FontStyle), aviso.FontStyle), FontStyle))
|
||||
rtbZeile1.SelectionColor = Color.FromName(aviso.TextColor)
|
||||
rtbZeile1.BackColor = Color.FromName(aviso.BackColor)
|
||||
|
||||
Select Case aviso.TextAlignment
|
||||
Case "Left"
|
||||
rtbZeile1.SelectionAlignment = HorizontalAlignment.Left
|
||||
Case "Center"
|
||||
rtbZeile1.SelectionAlignment = HorizontalAlignment.Center
|
||||
Case "Right"
|
||||
rtbZeile1.SelectionAlignment = HorizontalAlignment.Right
|
||||
Case Else
|
||||
rtbZeile1.SelectionAlignment = HorizontalAlignment.Left
|
||||
End Select
|
||||
|
||||
grpWochentage.Enabled = chkIsRecurring.Checked
|
||||
End Sub
|
||||
|
||||
Private Function ConvertRtfToHtml(rtf As String) As String
|
||||
Using rtb As New RichTextBox()
|
||||
rtb.Rtf = rtf
|
||||
Dim sb As New System.Text.StringBuilder()
|
||||
|
||||
' Initialisiere die HTML-Struktur
|
||||
sb.Append("<html><body>")
|
||||
|
||||
Dim currentFont As System.Drawing.Font = rtb.SelectionFont
|
||||
Dim currentColor As Color = rtb.SelectionColor
|
||||
Dim currentAlignment As HorizontalAlignment = rtb.SelectionAlignment
|
||||
|
||||
Dim text As String = rtb.Text
|
||||
Dim index As Integer = 0
|
||||
|
||||
While index < text.Length
|
||||
rtb.Select(index, 1)
|
||||
Dim font As System.Drawing.Font = rtb.SelectionFont
|
||||
Dim color As Color = rtb.SelectionColor
|
||||
Dim alignment As HorizontalAlignment = rtb.SelectionAlignment
|
||||
|
||||
' Beginne neue Tags, wenn sich das Format ändert
|
||||
If font IsNot currentFont Then
|
||||
' Schließe vorherige Font-Tags
|
||||
If currentFont IsNot Nothing Then
|
||||
sb.Append("</span></span>")
|
||||
End If
|
||||
|
||||
' Öffne neue Font-Tags
|
||||
sb.Append("<span style=""font-family:" & font.FontFamily.Name & "; font-size:" & font.Size.ToString() & "pt;"">")
|
||||
sb.Append("<span style=""color:" & color.Name & ";"">")
|
||||
|
||||
currentFont = font
|
||||
currentColor = color
|
||||
End If
|
||||
|
||||
If alignment <> currentAlignment Then
|
||||
' Schließe vorherige Ausrichtung
|
||||
Select Case currentAlignment
|
||||
Case HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right
|
||||
sb.Append("</div>")
|
||||
End Select
|
||||
|
||||
' Öffne neue Ausrichtung
|
||||
Select Case alignment
|
||||
Case HorizontalAlignment.Left
|
||||
sb.Append("<div style=""text-align:left;"">")
|
||||
Case HorizontalAlignment.Center
|
||||
sb.Append("<div style=""text-align:center;"">")
|
||||
Case HorizontalAlignment.Right
|
||||
sb.Append("<div style=""text-align:right;"">")
|
||||
End Select
|
||||
|
||||
currentAlignment = alignment
|
||||
End If
|
||||
|
||||
' Füge das aktuelle Zeichen hinzu (HTML-encodiert)
|
||||
Dim currentChar As Char = text(index)
|
||||
Select Case currentChar
|
||||
Case "<"
|
||||
sb.Append("<")
|
||||
Case ">"
|
||||
sb.Append(">")
|
||||
Case "&"
|
||||
sb.Append("&")
|
||||
Case Else
|
||||
sb.Append(currentChar)
|
||||
End Select
|
||||
|
||||
index += 1
|
||||
End While
|
||||
|
||||
' Schließe verbleibende Tags
|
||||
If currentFont IsNot Nothing Then
|
||||
sb.Append("</span></span>")
|
||||
End If
|
||||
|
||||
Select Case currentAlignment
|
||||
Case HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right
|
||||
sb.Append("</div>")
|
||||
End Select
|
||||
|
||||
sb.Append("</body></html>")
|
||||
Return sb.ToString()
|
||||
End Using
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Private Sub btnSpeichern_Click(sender As Object, e As EventArgs) Handles btnSpeichern.Click
|
||||
Dim verwendeteTvTextBezeichnung As String = ""
|
||||
Dim isNeueTvTextBezeichnung As Boolean = False
|
||||
@@ -376,6 +594,10 @@ Public Class frmEintragTvNew
|
||||
End If
|
||||
|
||||
Try
|
||||
' Konvertiere RTF zu HTML
|
||||
Dim rtfContent As String = rtbZeile1.Rtf
|
||||
Dim htmlContent As String = ConvertRtfToHtml(rtfContent)
|
||||
|
||||
myAvisoTvNew.TvTextBezeichnung = verwendeteTvTextBezeichnung
|
||||
myAvisoTvNew.StandortID = currentStandortID
|
||||
If cmbPosition.SelectedIndex >= 0 Then
|
||||
@@ -393,7 +615,9 @@ Public Class frmEintragTvNew
|
||||
myAvisoTvNew.TvTextBezeichnungID = selectedTvTextBezeichnungID
|
||||
End If
|
||||
|
||||
myAvisoTvNew.FixeZeile1 = If(String.IsNullOrWhiteSpace(txtZeile1.Text), Nothing, txtZeile1.Text.Trim())
|
||||
' Speichere den HTML-Inhalt
|
||||
myAvisoTvNew.FixeZeile1RTF = If(String.IsNullOrWhiteSpace(rtbZeile1.Text), Nothing, rtfContent)
|
||||
myAvisoTvNew.FixeZeile1HTML = If(String.IsNullOrWhiteSpace(rtbZeile1.Text), Nothing, htmlContent)
|
||||
myAvisoTvNew.FixeZeile2 = If(String.IsNullOrWhiteSpace(txtZeile2.Text), Nothing, txtZeile2.Text.Trim())
|
||||
myAvisoTvNew.FixeZeile3 = If(String.IsNullOrWhiteSpace(txtZeile3.Text), Nothing, txtZeile3.Text.Trim())
|
||||
|
||||
@@ -415,6 +639,7 @@ Public Class frmEintragTvNew
|
||||
|
||||
myAvisoTvNew.IsActive = chkIsActive.Checked
|
||||
|
||||
|
||||
If Neuanlage Then
|
||||
myAvisoTvNew.Standort = cbxStandort.SelectedItem?.ToString()
|
||||
If String.IsNullOrEmpty(myAvisoTvNew.Standort) Then
|
||||
@@ -425,6 +650,7 @@ Public Class frmEintragTvNew
|
||||
|
||||
Debug.WriteLine($"Speichern: TVID = {myAvisoTvNew.TVID}, TvTextBezeichnungID = {myAvisoTvNew.TvTextBezeichnungID}, StandortID = {myAvisoTvNew.StandortID}")
|
||||
|
||||
' Speichern der Einstellungen
|
||||
AvisoTvNewDAL.SpeichernAvisoTvNew(myAvisoTvNew)
|
||||
|
||||
LadeTvTextBezeichnungen()
|
||||
@@ -448,6 +674,8 @@ Public Class frmEintragTvNew
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub btnLoeschen_Click(sender As Object, e As EventArgs) Handles btnLoeschen.Click
|
||||
If myAvisoTvNew Is Nothing OrElse myAvisoTvNew.TVID = 0 Then
|
||||
MessageBox.Show("Bitte wählen Sie einen Eintrag zum Deaktivieren aus.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
@@ -493,7 +721,7 @@ Public Class frmEintragTvNew
|
||||
Me.Close()
|
||||
End Sub
|
||||
|
||||
Private Sub txt_TextChanged(sender As Object, e As EventArgs) Handles txtZeile1.TextChanged, txtZeile2.TextChanged, txtZeile3.TextChanged, dtpStartDate.ValueChanged, dtpEndDate.ValueChanged, dtpStartTime.ValueChanged, dtpEndTime.ValueChanged, chkIsRecurring.CheckedChanged, chkMonday.CheckedChanged, chkTuesday.CheckedChanged, chkWednesday.CheckedChanged, chkThursday.CheckedChanged, chkFriday.CheckedChanged, chkSaturday.CheckedChanged, chkSunday.CheckedChanged, chkIsActive.CheckedChanged, cmbTvTextBezeichnungAuswahl.SelectedIndexChanged, txtNeueTvTextBezeichnung.TextChanged
|
||||
Private Sub txt_TextChanged(sender As Object, e As EventArgs) Handles rtbZeile1.TextChanged, txtZeile2.TextChanged, txtZeile3.TextChanged, dtpStartDate.ValueChanged, dtpEndDate.ValueChanged, dtpStartTime.ValueChanged, dtpEndTime.ValueChanged, chkIsRecurring.CheckedChanged, chkMonday.CheckedChanged, chkTuesday.CheckedChanged, chkWednesday.CheckedChanged, chkThursday.CheckedChanged, chkFriday.CheckedChanged, chkSaturday.CheckedChanged, chkSunday.CheckedChanged, chkIsActive.CheckedChanged, cmbTvTextBezeichnungAuswahl.SelectedIndexChanged, txtNeueTvTextBezeichnung.TextChanged
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
@@ -512,7 +740,7 @@ Public Class frmEintragTvNew
|
||||
cmbTvTextBezeichnungAuswahl.SelectedIndex = -1
|
||||
cmbPosition.SelectedIndex = -1
|
||||
txtNeueTvTextBezeichnung.Text = ""
|
||||
txtZeile1.Text = ""
|
||||
rtbZeile1.Text = ""
|
||||
txtZeile2.Text = ""
|
||||
txtZeile3.Text = ""
|
||||
dtpStartDate.Value = DateTime.Now
|
||||
|
||||
Reference in New Issue
Block a user