TVAPP
This commit is contained in:
@@ -12,6 +12,9 @@ Public Class frmEintragTvNew
|
||||
|
||||
Private isInitializing As Boolean = False
|
||||
|
||||
' **Neue Klassenvariable zur Speicherung der zuletzt ausgewählten TVID**
|
||||
Private lastSelectedTVID As Integer = 0
|
||||
|
||||
Public Sub New()
|
||||
InitializeComponent()
|
||||
InitializeFontComboBoxes()
|
||||
@@ -89,11 +92,13 @@ Public Class frmEintragTvNew
|
||||
|
||||
If gefilterteListe.Count > 0 Then
|
||||
dgvAVISOTV.DataSource = gefilterteListe
|
||||
|
||||
' Anpassen der Spaltenüberschriften
|
||||
dgvAVISOTV.Columns("TvTextBezeichnungID").HeaderText = "ID"
|
||||
dgvAVISOTV.Columns("TvTextBezeichnung").HeaderText = "Bezeichnung"
|
||||
dgvAVISOTV.Columns("FixeZeile1RTF").HeaderText = "Zeile 1"
|
||||
dgvAVISOTV.Columns("FixeZeile2").HeaderText = "Zeile 2"
|
||||
dgvAVISOTV.Columns("FixeZeile3").HeaderText = "Zeile 3"
|
||||
dgvAVISOTV.Columns("FixeZeile1RTF").HeaderText = "Zeile 1 (Text)"
|
||||
dgvAVISOTV.Columns("FixeZeile2RTF").HeaderText = "Zeile 2 (Text)"
|
||||
dgvAVISOTV.Columns("FixeZeile3RTF").HeaderText = "Zeile 3 (Text)"
|
||||
dgvAVISOTV.Columns("Standort").Visible = False
|
||||
dgvAVISOTV.Columns("Art").Visible = False
|
||||
dgvAVISOTV.Columns("StartDate").HeaderText = "Startdatum"
|
||||
@@ -110,11 +115,30 @@ Public Class frmEintragTvNew
|
||||
dgvAVISOTV.Columns("IsSaturday").Visible = False
|
||||
dgvAVISOTV.Columns("IsSunday").Visible = False
|
||||
|
||||
' Hinzufügen des CellFormatting-Handlers
|
||||
AddHandler dgvAVISOTV.CellFormatting, AddressOf dgvAVISOTV_CellFormatting
|
||||
|
||||
dgvAVISOTV.AutoResizeColumns()
|
||||
|
||||
AddHandler dgvAVISOTV.SelectionChanged, AddressOf dgvAVISOTV_SelectionChanged
|
||||
|
||||
If dgvAVISOTV.Rows.Count > 0 Then
|
||||
' **Wiederherstellung der Auswahl basierend auf lastSelectedTVID**
|
||||
If lastSelectedTVID <> 0 Then
|
||||
Dim rowToSelect = dgvAVISOTV.Rows.Cast(Of DataGridViewRow)().FirstOrDefault(Function(r) CType(r.DataBoundItem, cAvisoTvNew).TvTextBezeichnungID = lastSelectedTVID)
|
||||
If rowToSelect IsNot Nothing Then
|
||||
rowToSelect.Selected = True
|
||||
|
||||
dgvAVISOTV.FirstDisplayedScrollingRowIndex = rowToSelect.Index
|
||||
dgvAVISOTV.CurrentCell = rowToSelect.Cells(0)
|
||||
Else
|
||||
' Falls die TVID nicht gefunden wird, wähle die erste Zeile aus
|
||||
If dgvAVISOTV.Rows.Count > 0 Then
|
||||
dgvAVISOTV.Rows(0).Selected = True
|
||||
dgvAVISOTV.CurrentCell = dgvAVISOTV.Rows(0).Cells(0)
|
||||
dgvAVISOTV_SelectionChanged(Nothing, Nothing)
|
||||
End If
|
||||
End If
|
||||
ElseIf dgvAVISOTV.Rows.Count > 0 Then
|
||||
dgvAVISOTV.Rows(0).Selected = True
|
||||
dgvAVISOTV.CurrentCell = dgvAVISOTV.Rows(0).Cells(0)
|
||||
dgvAVISOTV_SelectionChanged(Nothing, Nothing)
|
||||
@@ -133,6 +157,27 @@ Public Class frmEintragTvNew
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub dgvAVISOTV_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs)
|
||||
' Definieren Sie die Namen der RTF-Spalten
|
||||
Dim rtfColumns As String() = {"FixeZeile1RTF", "FixeZeile2RTF", "FixeZeile3RTF"}
|
||||
|
||||
' Überprüfen Sie, ob die aktuelle Spalte eine der RTF-Spalten ist
|
||||
If rtfColumns.Contains(dgvAVISOTV.Columns(e.ColumnIndex).Name) AndAlso e.Value IsNot Nothing Then
|
||||
Try
|
||||
' Konvertieren Sie den RTF-Text in normalen Text
|
||||
Using rtb As New RichTextBox()
|
||||
rtb.Rtf = e.Value.ToString()
|
||||
e.Value = rtb.Text
|
||||
e.FormattingApplied = True
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
' Falls das RTF ungültig ist, zeigen Sie den Originalwert an
|
||||
e.Value = e.Value.ToString()
|
||||
e.FormattingApplied = True
|
||||
End Try
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub cbxStandort_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxStandort.SelectedValueChanged
|
||||
If list IsNot Nothing Then list.Clear()
|
||||
|
||||
@@ -186,8 +231,6 @@ Public Class frmEintragTvNew
|
||||
End Function
|
||||
End Class
|
||||
|
||||
|
||||
|
||||
Private Sub cmbTvTextBezeichnungAuswahl_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbTvTextBezeichnungAuswahl.SelectedIndexChanged
|
||||
If isInitializing Then
|
||||
Return
|
||||
@@ -218,7 +261,7 @@ Public Class frmEintragTvNew
|
||||
Dim currentStandortID As Integer = AvisoTvNewDAL.GetStandortID(currentStandort)
|
||||
|
||||
If selectedAviso IsNot Nothing Then
|
||||
Debug.WriteLine("Gefundenes Aviso: TVID = " & selectedAviso.TVID)
|
||||
Debug.WriteLine("Gefundenes Aviso: TVID = " & selectedAviso.TvTextBezeichnungID)
|
||||
myAvisoTvNew = selectedAviso
|
||||
Neuanlage = False
|
||||
FillFieldsFromAviso(selectedAviso)
|
||||
@@ -241,12 +284,13 @@ 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
|
||||
|
||||
' Initialisierung für Zeile 1
|
||||
cmbFontFamily.DataSource = fontFamilies
|
||||
cmbFontFamily.SelectedItem = rtbZeile1.Font.FontFamily.Name
|
||||
|
||||
@@ -257,10 +301,27 @@ Public Class frmEintragTvNew
|
||||
AddHandler cmbFontFamily.SelectedIndexChanged, AddressOf cmbFontFamily_SelectedIndexChanged
|
||||
AddHandler cmbFontSize.SelectedIndexChanged, AddressOf cmbFontSize_SelectedIndexChanged
|
||||
|
||||
' Initialisierung für Zeile 2
|
||||
cmbFontFamily2.DataSource = New List(Of String)(fontFamilies)
|
||||
cmbFontFamily2.SelectedItem = rtbZeile2.Font.FontFamily.Name
|
||||
|
||||
cmbFontSize2.DataSource = sizes.Select(Function(s) s.ToString()).ToList()
|
||||
cmbFontSize2.SelectedItem = CInt(rtbZeile2.Font.Size).ToString()
|
||||
|
||||
AddHandler cmbFontFamily2.SelectedIndexChanged, AddressOf cmbFontFamily2_SelectedIndexChanged
|
||||
AddHandler cmbFontSize2.SelectedIndexChanged, AddressOf cmbFontSize2_SelectedIndexChanged
|
||||
|
||||
' Initialisierung für Zeile 3
|
||||
cmbFontFamily3.DataSource = New List(Of String)(fontFamilies)
|
||||
cmbFontFamily3.SelectedItem = rtbZeile3.Font.FontFamily.Name
|
||||
|
||||
cmbFontSize3.DataSource = sizes.Select(Function(s) s.ToString()).ToList()
|
||||
cmbFontSize3.SelectedItem = CInt(rtbZeile3.Font.Size).ToString()
|
||||
|
||||
AddHandler cmbFontFamily3.SelectedIndexChanged, AddressOf cmbFontFamily3_SelectedIndexChanged
|
||||
AddHandler cmbFontSize3.SelectedIndexChanged, AddressOf cmbFontSize3_SelectedIndexChanged
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
' Schriftfamilie ComboBox SelectionChanged
|
||||
Private Sub cmbFontFamily_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
UpdateFont()
|
||||
@@ -270,11 +331,25 @@ Public Class frmEintragTvNew
|
||||
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 selectedFontFamily As String = If(cmbFontFamily.SelectedItem, rtbZeile1.SelectionFont?.FontFamily.Name)
|
||||
Dim selectedFontSize As Single
|
||||
If Single.TryParse(cmbFontSize.SelectedItem, selectedFontSize) Then
|
||||
rtbZeile1.Font = New Font(selectedFontFamily, selectedFontSize, rtbZeile1.Font.Style)
|
||||
' Überprüfen, ob eine Auswahl vorhanden ist
|
||||
If rtbZeile1.SelectionLength > 0 Then
|
||||
' Erstellen einer neuen Schriftart basierend auf der Auswahl
|
||||
Dim currentFont As Font = rtbZeile1.SelectionFont
|
||||
If currentFont IsNot Nothing Then
|
||||
rtbZeile1.SelectionFont = New Font(selectedFontFamily, selectedFontSize, currentFont.Style)
|
||||
Else
|
||||
' Wenn die Auswahl unterschiedliche Schriftarten hat, eine neue Schriftart setzen
|
||||
rtbZeile1.SelectionFont = New Font(selectedFontFamily, selectedFontSize)
|
||||
End If
|
||||
Else
|
||||
' Wenn keine Auswahl vorhanden ist, setzen Sie die Standard-Schriftart der RichTextBox
|
||||
rtbZeile1.Font = New Font(selectedFontFamily, selectedFontSize, rtbZeile1.Font.Style)
|
||||
End If
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
@@ -348,6 +423,208 @@ Public Class frmEintragTvNew
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
' Schriftfamilie ComboBox SelectionChanged
|
||||
Private Sub cmbFontFamily2_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
UpdateFont2()
|
||||
End Sub
|
||||
|
||||
' Schriftgröße ComboBox SelectionChanged
|
||||
Private Sub cmbFontSize2_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
UpdateFont2()
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateFont2()
|
||||
Dim selectedFontFamily As String = If(cmbFontFamily2.SelectedItem, rtbZeile2.SelectionFont?.FontFamily.Name)
|
||||
Dim selectedFontSize As Single
|
||||
If Single.TryParse(cmbFontSize2.SelectedItem, selectedFontSize) Then
|
||||
' Überprüfen, ob eine Auswahl vorhanden ist
|
||||
If rtbZeile2.SelectionLength > 0 Then
|
||||
' Erstellen einer neuen Schriftart basierend auf der Auswahl
|
||||
Dim currentFont As Font = rtbZeile2.SelectionFont
|
||||
If currentFont IsNot Nothing Then
|
||||
rtbZeile2.SelectionFont = New Font(selectedFontFamily, selectedFontSize, currentFont.Style)
|
||||
Else
|
||||
' Wenn die Auswahl unterschiedliche Schriftarten hat, eine neue Schriftart setzen
|
||||
rtbZeile2.SelectionFont = New Font(selectedFontFamily, selectedFontSize)
|
||||
End If
|
||||
Else
|
||||
' Wenn keine Auswahl vorhanden ist, setzen Sie die Standard-Schriftart der RichTextBox
|
||||
rtbZeile2.Font = New Font(selectedFontFamily, selectedFontSize, rtbZeile2.Font.Style)
|
||||
End If
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Methode zum Umschalten des Schriftstils
|
||||
Private Sub ToggleFontStyle2(style As FontStyle)
|
||||
If rtbZeile2.SelectionFont IsNot Nothing Then
|
||||
Dim currentFont As Font = rtbZeile2.SelectionFont
|
||||
Dim newFontStyle As FontStyle
|
||||
|
||||
If rtbZeile2.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
|
||||
rtbZeile2.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, newFontStyle)
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Fett (Bold) Button Click
|
||||
Private Sub btnBold2_Click(sender As Object, e As EventArgs) Handles btnBold2.Click
|
||||
ToggleFontStyle2(FontStyle.Bold)
|
||||
End Sub
|
||||
|
||||
' Kursiv (Italic) Button Click
|
||||
Private Sub btnItalic2_Click(sender As Object, e As EventArgs) Handles btnItalic2.Click
|
||||
ToggleFontStyle2(FontStyle.Italic)
|
||||
End Sub
|
||||
|
||||
' Unterstrichen (Underline) Button Click
|
||||
Private Sub btnUnderline2_Click(sender As Object, e As EventArgs) Handles btnUnderline2.Click
|
||||
ToggleFontStyle2(FontStyle.Underline)
|
||||
End Sub
|
||||
|
||||
' Textfarbe ändern Button Click
|
||||
Private Sub btnTextColor2_Click(sender As Object, e As EventArgs) Handles btnTextColor2.Click
|
||||
If colorDialogText.ShowDialog() = DialogResult.OK Then
|
||||
rtbZeile2.SelectionColor = colorDialogText.Color
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Hintergrundfarbe ändern Button Click
|
||||
Private Sub btnBackColor2_Click(sender As Object, e As EventArgs) Handles btnBackColor2.Click
|
||||
If colorDialogText.ShowDialog() = DialogResult.OK Then
|
||||
rtbZeile2.SelectionBackColor = colorDialogText.Color
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Links ausrichten Button Click
|
||||
Private Sub btnAlignLeft2_Click(sender As Object, e As EventArgs) Handles btnAlignLeft2.Click
|
||||
rtbZeile2.SelectionAlignment = HorizontalAlignment.Left
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
' Mitte ausrichten Button Click
|
||||
Private Sub btnAlignCenter2_Click(sender As Object, e As EventArgs) Handles btnAlignCenter2.Click
|
||||
rtbZeile2.SelectionAlignment = HorizontalAlignment.Center
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
' Rechts ausrichten Button Click
|
||||
Private Sub btnAlignRight2_Click(sender As Object, e As EventArgs) Handles btnAlignRight2.Click
|
||||
rtbZeile2.SelectionAlignment = HorizontalAlignment.Right
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
' Schriftfamilie ComboBox SelectionChanged
|
||||
Private Sub cmbFontFamily3_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
UpdateFont3()
|
||||
End Sub
|
||||
|
||||
' Schriftgröße ComboBox SelectionChanged
|
||||
Private Sub cmbFontSize3_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
UpdateFont3()
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateFont3()
|
||||
Dim selectedFontFamily As String = If(cmbFontFamily3.SelectedItem, rtbZeile3.SelectionFont?.FontFamily.Name)
|
||||
Dim selectedFontSize As Single
|
||||
If Single.TryParse(cmbFontSize3.SelectedItem, selectedFontSize) Then
|
||||
' Überprüfen, ob eine Auswahl vorhanden ist
|
||||
If rtbZeile3.SelectionLength > 0 Then
|
||||
' Erstellen einer neuen Schriftart basierend auf der Auswahl
|
||||
Dim currentFont As Font = rtbZeile3.SelectionFont
|
||||
If currentFont IsNot Nothing Then
|
||||
rtbZeile3.SelectionFont = New Font(selectedFontFamily, selectedFontSize, currentFont.Style)
|
||||
Else
|
||||
' Wenn die Auswahl unterschiedliche Schriftarten hat, eine neue Schriftart setzen
|
||||
rtbZeile3.SelectionFont = New Font(selectedFontFamily, selectedFontSize)
|
||||
End If
|
||||
Else
|
||||
' Wenn keine Auswahl vorhanden ist, setzen Sie die Standard-Schriftart der RichTextBox
|
||||
rtbZeile3.Font = New Font(selectedFontFamily, selectedFontSize, rtbZeile3.Font.Style)
|
||||
End If
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Methode zum Umschalten des Schriftstils
|
||||
Private Sub ToggleFontStyle3(style As FontStyle)
|
||||
If rtbZeile3.SelectionFont IsNot Nothing Then
|
||||
Dim currentFont As Font = rtbZeile3.SelectionFont
|
||||
Dim newFontStyle As FontStyle
|
||||
|
||||
If rtbZeile3.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
|
||||
rtbZeile3.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, newFontStyle)
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Fett (Bold) Button Click
|
||||
Private Sub btnBold3_Click(sender As Object, e As EventArgs) Handles btnBold3.Click
|
||||
ToggleFontStyle3(FontStyle.Bold)
|
||||
End Sub
|
||||
|
||||
' Kursiv (Italic) Button Click
|
||||
Private Sub btnItalic3_Click(sender As Object, e As EventArgs) Handles btnItalic3.Click
|
||||
ToggleFontStyle3(FontStyle.Italic)
|
||||
End Sub
|
||||
|
||||
' Unterstrichen (Underline) Button Click
|
||||
Private Sub btnUnderline3_Click(sender As Object, e As EventArgs) Handles btnUnderline3.Click
|
||||
ToggleFontStyle3(FontStyle.Underline)
|
||||
End Sub
|
||||
|
||||
' Textfarbe ändern Button Click
|
||||
Private Sub btnTextColor3_Click(sender As Object, e As EventArgs) Handles btnTextColor3.Click
|
||||
If colorDialogText.ShowDialog() = DialogResult.OK Then
|
||||
rtbZeile3.SelectionColor = colorDialogText.Color
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Hintergrundfarbe ändern Button Click
|
||||
Private Sub btnBackColor3_Click(sender As Object, e As EventArgs) Handles btnBackColor3.Click
|
||||
If colorDialogText.ShowDialog() = DialogResult.OK Then
|
||||
rtbZeile3.SelectionBackColor = colorDialogText.Color
|
||||
hatAenderung = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' Links ausrichten Button Click
|
||||
Private Sub btnAlignLeft3_Click(sender As Object, e As EventArgs) Handles btnAlignLeft3.Click
|
||||
rtbZeile3.SelectionAlignment = HorizontalAlignment.Left
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
' Mitte ausrichten Button Click
|
||||
Private Sub btnAlignCenter3_Click(sender As Object, e As EventArgs) Handles btnAlignCenter3.Click
|
||||
rtbZeile3.SelectionAlignment = HorizontalAlignment.Center
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
' Rechts ausrichten Button Click
|
||||
Private Sub btnAlignRight3_Click(sender As Object, e As EventArgs) Handles btnAlignRight3.Click
|
||||
rtbZeile3.SelectionAlignment = HorizontalAlignment.Right
|
||||
hatAenderung = True
|
||||
End Sub
|
||||
|
||||
Private Sub LadeTvTextBezeichnungen()
|
||||
isInitializing = True
|
||||
Dim bezeichnungen As New List(Of cTvTextBezeichnung)()
|
||||
@@ -407,8 +684,8 @@ Public Class frmEintragTvNew
|
||||
|
||||
' Hier setzt du die Textzeilen, wenn vorhanden
|
||||
rtbZeile1.Rtf = aviso.FixeZeile1RTF
|
||||
txtZeile2.Text = aviso.FixeZeile2
|
||||
txtZeile3.Text = aviso.FixeZeile3
|
||||
rtbZeile2.Rtf = aviso.FixeZeile2RTF
|
||||
rtbZeile3.Rtf = aviso.FixeZeile3RTF
|
||||
|
||||
chkIsRecurring.Checked = aviso.IsRecurring.GetValueOrDefault(False)
|
||||
|
||||
@@ -454,23 +731,6 @@ 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
|
||||
@@ -483,87 +743,135 @@ Public Class frmEintragTvNew
|
||||
' 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
|
||||
' Teile den Text in Absätze auf
|
||||
Dim paragraphs As String() = rtb.Text.Split(New String() {vbCrLf, vbLf}, StringSplitOptions.None)
|
||||
|
||||
Dim text As String = rtb.Text
|
||||
Dim index As Integer = 0
|
||||
Dim charIndex 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
|
||||
For Each paragraph As String In paragraphs
|
||||
' Wähle den aktuellen Absatz aus
|
||||
rtb.Select(charIndex, paragraph.Length)
|
||||
|
||||
' Erhalte die Ausrichtung des aktuellen Absatzes
|
||||
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("&")
|
||||
' Öffne einen Div-Tag mit der entsprechenden Textausrichtung
|
||||
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;"">")
|
||||
Case Else
|
||||
sb.Append(currentChar)
|
||||
sb.Append("<div>")
|
||||
End Select
|
||||
|
||||
index += 1
|
||||
End While
|
||||
' Setze die aktuellen Formatierungsvariablen auf Nothing/Empty, um beim ersten Zeichen zu starten
|
||||
Dim currentFont As System.Drawing.Font = Nothing
|
||||
Dim currentColor As Color = Color.Empty
|
||||
Dim currentBackColor As Color = Color.Empty
|
||||
Dim currentBold As Boolean = False
|
||||
Dim currentItalic As Boolean = False
|
||||
Dim currentUnderline As Boolean = False
|
||||
|
||||
' Schließe verbleibende Tags
|
||||
If currentFont IsNot Nothing Then
|
||||
sb.Append("</span></span>")
|
||||
End If
|
||||
' Iteriere durch die Zeichen im Absatz
|
||||
For i As Integer = 0 To paragraph.Length - 1
|
||||
Dim globalIndex As Integer = charIndex + i
|
||||
rtb.Select(globalIndex, 1)
|
||||
Dim font As System.Drawing.Font = rtb.SelectionFont
|
||||
Dim color As Color = rtb.SelectionColor
|
||||
Dim backColor As Color = rtb.SelectionBackColor
|
||||
|
||||
Select Case currentAlignment
|
||||
Case HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right
|
||||
sb.Append("</div>")
|
||||
End Select
|
||||
' Bestimme die Schriftstile
|
||||
Dim isBold As Boolean = font IsNot Nothing AndAlso font.Bold
|
||||
Dim isItalic As Boolean = font IsNot Nothing AndAlso font.Italic
|
||||
Dim isUnderline As Boolean = font IsNot Nothing AndAlso font.Underline
|
||||
|
||||
' Überprüfe, ob sich die Formatierung geändert hat
|
||||
If font IsNot currentFont OrElse color <> currentColor OrElse backColor <> currentBackColor OrElse isBold <> currentBold OrElse isItalic <> currentItalic OrElse isUnderline <> currentUnderline Then
|
||||
' Schließe vorherige Font-, Farb- und Hintergrundfarb-Tags
|
||||
If currentFont IsNot Nothing OrElse color <> Color.Empty OrElse backColor <> Color.Empty OrElse currentBold OrElse currentItalic OrElse currentUnderline Then
|
||||
sb.Append("</span>")
|
||||
End If
|
||||
|
||||
' Öffne ein neues Span-Tag mit den aktuellen Stilen
|
||||
Dim style As New System.Text.StringBuilder()
|
||||
|
||||
If font IsNot Nothing Then
|
||||
style.Append($"font-family:{font.FontFamily.Name}; ")
|
||||
style.Append($"font-size:{font.SizeInPoints}pt; ")
|
||||
End If
|
||||
|
||||
If color <> Color.Empty Then
|
||||
style.Append($"color:{ColorTranslator.ToHtml(color)}; ")
|
||||
End If
|
||||
|
||||
If backColor <> Color.Empty Then
|
||||
style.Append($"background-color:{ColorTranslator.ToHtml(backColor)}; ")
|
||||
End If
|
||||
|
||||
If isBold Then
|
||||
style.Append($"font-weight:bold; ")
|
||||
End If
|
||||
|
||||
If isItalic Then
|
||||
style.Append($"font-style:italic; ")
|
||||
End If
|
||||
|
||||
If isUnderline Then
|
||||
style.Append($"text-decoration:underline; ")
|
||||
End If
|
||||
|
||||
If style.Length > 0 Then
|
||||
sb.Append($"<span style=""{style.ToString().Trim()}"">")
|
||||
End If
|
||||
|
||||
' Aktualisiere die aktuellen Formatierungsvariablen
|
||||
currentFont = font
|
||||
currentColor = color
|
||||
currentBackColor = backColor
|
||||
currentBold = isBold
|
||||
currentItalic = isItalic
|
||||
currentUnderline = isUnderline
|
||||
End If
|
||||
|
||||
' Füge das aktuelle Zeichen hinzu (HTML-encodiert)
|
||||
Dim currentChar As Char = paragraph(i)
|
||||
Select Case currentChar
|
||||
Case "<"
|
||||
sb.Append("<")
|
||||
Case ">"
|
||||
sb.Append(">")
|
||||
Case "&"
|
||||
sb.Append("&")
|
||||
Case Else
|
||||
sb.Append(currentChar)
|
||||
End Select
|
||||
Next
|
||||
|
||||
' Schließe verbleibende Tags im Absatz
|
||||
If currentFont IsNot Nothing OrElse currentColor <> Color.Empty OrElse currentBackColor <> Color.Empty OrElse currentBold OrElse currentItalic OrElse currentUnderline Then
|
||||
sb.Append("</span>")
|
||||
End If
|
||||
|
||||
' Schließe den Div-Tag für den Absatz
|
||||
sb.Append("</div>")
|
||||
|
||||
' Aktualisiere den charIndex für den nächsten Absatz (+2 für vbCrLf, könnte je nach Zeilenumbrüchen variieren)
|
||||
' Überprüfe den tatsächlichen Zeilenumbruch und passe gegebenenfalls an
|
||||
If charIndex + paragraph.Length + 2 <= rtb.Text.Length Then
|
||||
charIndex += paragraph.Length + 2 ' Annahme: \r\n als Zeilenumbruch
|
||||
Else
|
||||
charIndex += paragraph.Length
|
||||
End If
|
||||
Next
|
||||
|
||||
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
|
||||
@@ -594,10 +902,21 @@ Public Class frmEintragTvNew
|
||||
End If
|
||||
|
||||
Try
|
||||
' **Speichern der TVID der aktuell ausgewählten Zeile**
|
||||
If dgvAVISOTV.CurrentRow IsNot Nothing AndAlso dgvAVISOTV.CurrentRow.DataBoundItem IsNot Nothing Then
|
||||
Dim selectedAviso As cAvisoTvNew = CType(dgvAVISOTV.CurrentRow.DataBoundItem, cAvisoTvNew)
|
||||
If selectedAviso IsNot Nothing Then
|
||||
lastSelectedTVID = selectedAviso.TvTextBezeichnungID
|
||||
End If
|
||||
End If
|
||||
|
||||
' Konvertiere RTF zu HTML
|
||||
Dim rtfContent As String = rtbZeile1.Rtf
|
||||
Dim htmlContent As String = ConvertRtfToHtml(rtfContent)
|
||||
|
||||
Dim rtfContent2 As String = rtbZeile2.Rtf
|
||||
Dim htmlContent2 As String = ConvertRtfToHtml(rtfContent2)
|
||||
Dim rtfContent3 As String = rtbZeile3.Rtf
|
||||
Dim htmlContent3 As String = ConvertRtfToHtml(rtfContent3)
|
||||
myAvisoTvNew.TvTextBezeichnung = verwendeteTvTextBezeichnung
|
||||
myAvisoTvNew.StandortID = currentStandortID
|
||||
If cmbPosition.SelectedIndex >= 0 Then
|
||||
@@ -618,8 +937,10 @@ Public Class frmEintragTvNew
|
||||
' 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())
|
||||
myAvisoTvNew.FixeZeile2RTF = If(String.IsNullOrWhiteSpace(rtbZeile2.Text), Nothing, rtfContent2)
|
||||
myAvisoTvNew.FixeZeile2HTML = If(String.IsNullOrWhiteSpace(rtbZeile2.Text), Nothing, htmlContent2)
|
||||
myAvisoTvNew.FixeZeile3RTF = If(String.IsNullOrWhiteSpace(rtbZeile3.Text), Nothing, rtfContent3)
|
||||
myAvisoTvNew.FixeZeile3HTML = If(String.IsNullOrWhiteSpace(rtbZeile3.Text), Nothing, htmlContent3)
|
||||
|
||||
myAvisoTvNew.IsRecurring = chkIsRecurring.Checked
|
||||
|
||||
@@ -639,7 +960,6 @@ Public Class frmEintragTvNew
|
||||
|
||||
myAvisoTvNew.IsActive = chkIsActive.Checked
|
||||
|
||||
|
||||
If Neuanlage Then
|
||||
myAvisoTvNew.Standort = cbxStandort.SelectedItem?.ToString()
|
||||
If String.IsNullOrEmpty(myAvisoTvNew.Standort) Then
|
||||
@@ -648,7 +968,7 @@ Public Class frmEintragTvNew
|
||||
End If
|
||||
End If
|
||||
|
||||
Debug.WriteLine($"Speichern: TVID = {myAvisoTvNew.TVID}, TvTextBezeichnungID = {myAvisoTvNew.TvTextBezeichnungID}, StandortID = {myAvisoTvNew.StandortID}")
|
||||
Debug.WriteLine($"Speichern: TVID = {myAvisoTvNew.TvTextBezeichnungID}, TvTextBezeichnungID = {myAvisoTvNew.TvTextBezeichnungID}, StandortID = {myAvisoTvNew.StandortID}")
|
||||
|
||||
' Speichern der Einstellungen
|
||||
AvisoTvNewDAL.SpeichernAvisoTvNew(myAvisoTvNew)
|
||||
@@ -658,10 +978,13 @@ Public Class frmEintragTvNew
|
||||
list.Clear()
|
||||
AvisoTvNewDAL.LesenAvisoTvNew(0, "", currentStandort, list)
|
||||
|
||||
' **Nach dem Speichern und Neuladen der Daten**
|
||||
initdgv()
|
||||
hatAenderung = False
|
||||
|
||||
If isNeueTvTextBezeichnung Then
|
||||
' **Setze lastSelectedTVID auf die TVID des neuen Eintrags**
|
||||
lastSelectedTVID = myAvisoTvNew.TvTextBezeichnungID
|
||||
MessageBox.Show("Die neue TvTextBezeichnung wurde erfolgreich gespeichert.", "Erfolg", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
cmbTvTextBezeichnungAuswahl.SelectedValue = myAvisoTvNew.TvTextBezeichnungID
|
||||
txtNeueTvTextBezeichnung.Text = ""
|
||||
@@ -674,10 +997,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
|
||||
If myAvisoTvNew Is Nothing OrElse myAvisoTvNew.TvTextBezeichnungID = 0 Then
|
||||
MessageBox.Show("Bitte wählen Sie einen Eintrag zum Deaktivieren aus.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
Return
|
||||
End If
|
||||
@@ -685,7 +1006,7 @@ Public Class frmEintragTvNew
|
||||
Dim antwort As DialogResult = MessageBox.Show("Möchten Sie den ausgewählten Eintrag wirklich deaktivieren?", "Deaktivieren bestätigen", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
|
||||
If antwort = DialogResult.Yes Then
|
||||
Try
|
||||
AvisoTvNewDAL.SetzeAufInaktiv(myAvisoTvNew.TVID)
|
||||
AvisoTvNewDAL.SetzeAufInaktiv(myAvisoTvNew.TvTextBezeichnungID)
|
||||
list.Clear()
|
||||
AvisoTvNewDAL.LesenAvisoTvNew(0, "", cbxStandort.SelectedItem?.ToString(), list)
|
||||
initdgv()
|
||||
@@ -721,7 +1042,7 @@ Public Class frmEintragTvNew
|
||||
Me.Close()
|
||||
End Sub
|
||||
|
||||
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
|
||||
Private Sub txt_TextChanged(sender As Object, e As EventArgs) Handles rtbZeile1.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
|
||||
|
||||
@@ -741,8 +1062,8 @@ Public Class frmEintragTvNew
|
||||
cmbPosition.SelectedIndex = -1
|
||||
txtNeueTvTextBezeichnung.Text = ""
|
||||
rtbZeile1.Text = ""
|
||||
txtZeile2.Text = ""
|
||||
txtZeile3.Text = ""
|
||||
rtbZeile2.Text = ""
|
||||
rtbZeile3.Text = ""
|
||||
dtpStartDate.Value = DateTime.Now
|
||||
dtpStartDate.Checked = False
|
||||
dtpEndDate.Value = DateTime.Now
|
||||
|
||||
Reference in New Issue
Block a user