diff --git a/Aviso/frmEintragTvNew.Designer.vb b/Aviso/frmEintragTvNew.Designer.vb index db735ae..4414fca 100644 --- a/Aviso/frmEintragTvNew.Designer.vb +++ b/Aviso/frmEintragTvNew.Designer.vb @@ -15,6 +15,20 @@ Partial Class frmEintragTvNew Private components As System.ComponentModel.IContainer + ' Neue Komponenten für Textformatierung + Private WithEvents btnBold As Button + Private WithEvents btnItalic As Button + Private WithEvents btnUnderline As Button + Private WithEvents btnTextColor As Button + Private WithEvents btnBackColor As Button + Private WithEvents btnAlignLeft As Button + Private WithEvents btnAlignCenter As Button + Private WithEvents btnAlignRight As Button + Private WithEvents cmbFontFamily As ComboBox + Private WithEvents cmbFontSize As ComboBox + Private WithEvents colorDialogText As ColorDialog + Private WithEvents rtbZeile1 As RichTextBox ' Geänderte TextBox zu RichTextBox + Private Sub InitializeComponent() Me.cbxStandort = New System.Windows.Forms.ComboBox() @@ -45,16 +59,27 @@ Partial Class frmEintragTvNew Me.lblZeile3 = New System.Windows.Forms.Label() Me.txtZeile2 = New System.Windows.Forms.TextBox() Me.lblZeile2 = New System.Windows.Forms.Label() - Me.txtZeile1 = New System.Windows.Forms.TextBox() + Me.rtbZeile1 = New System.Windows.Forms.RichTextBox() Me.lblZeile1 = New System.Windows.Forms.Label() Me.cmbTvTextBezeichnungAuswahl = New System.Windows.Forms.ComboBox() Me.lblBezeichnung = New System.Windows.Forms.Label() Me.lblPosition = New System.Windows.Forms.Label() Me.cmbPosition = New System.Windows.Forms.ComboBox() + Me.btnBold = New System.Windows.Forms.Button() + Me.btnItalic = New System.Windows.Forms.Button() + Me.btnUnderline = New System.Windows.Forms.Button() + Me.btnTextColor = New System.Windows.Forms.Button() + Me.btnBackColor = New System.Windows.Forms.Button() + Me.btnAlignLeft = New System.Windows.Forms.Button() + Me.btnAlignCenter = New System.Windows.Forms.Button() + Me.btnAlignRight = New System.Windows.Forms.Button() + Me.cmbFontFamily = New System.Windows.Forms.ComboBox() + Me.cmbFontSize = New System.Windows.Forms.ComboBox() Me.btnSpeichern = New System.Windows.Forms.Button() Me.btnLoeschen = New System.Windows.Forms.Button() Me.btnAbbrechen = New System.Windows.Forms.Button() Me.chkShowInactive = New System.Windows.Forms.CheckBox() + Me.colorDialogText = New System.Windows.Forms.ColorDialog() CType(Me.dgvAVISOTV, System.ComponentModel.ISupportInitialize).BeginInit() Me.grpEingabe.SuspendLayout() Me.grpWochentage.SuspendLayout() @@ -88,7 +113,7 @@ Partial Class frmEintragTvNew Me.dgvAVISOTV.Name = "dgvAVISOTV" Me.dgvAVISOTV.ReadOnly = True Me.dgvAVISOTV.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect - Me.dgvAVISOTV.Size = New System.Drawing.Size(977, 200) + Me.dgvAVISOTV.Size = New System.Drawing.Size(1300, 200) Me.dgvAVISOTV.TabIndex = 2 ' 'grpEingabe @@ -110,15 +135,25 @@ Partial Class frmEintragTvNew Me.grpEingabe.Controls.Add(Me.lblZeile3) Me.grpEingabe.Controls.Add(Me.txtZeile2) Me.grpEingabe.Controls.Add(Me.lblZeile2) - Me.grpEingabe.Controls.Add(Me.txtZeile1) + Me.grpEingabe.Controls.Add(Me.rtbZeile1) Me.grpEingabe.Controls.Add(Me.lblZeile1) Me.grpEingabe.Controls.Add(Me.cmbTvTextBezeichnungAuswahl) Me.grpEingabe.Controls.Add(Me.lblBezeichnung) Me.grpEingabe.Controls.Add(Me.lblPosition) Me.grpEingabe.Controls.Add(Me.cmbPosition) + Me.grpEingabe.Controls.Add(Me.btnBold) + Me.grpEingabe.Controls.Add(Me.btnItalic) + Me.grpEingabe.Controls.Add(Me.btnUnderline) + Me.grpEingabe.Controls.Add(Me.btnTextColor) + Me.grpEingabe.Controls.Add(Me.btnBackColor) + Me.grpEingabe.Controls.Add(Me.btnAlignLeft) + Me.grpEingabe.Controls.Add(Me.btnAlignCenter) + Me.grpEingabe.Controls.Add(Me.btnAlignRight) + Me.grpEingabe.Controls.Add(Me.cmbFontFamily) + Me.grpEingabe.Controls.Add(Me.cmbFontSize) Me.grpEingabe.Location = New System.Drawing.Point(15, 275) Me.grpEingabe.Name = "grpEingabe" - Me.grpEingabe.Size = New System.Drawing.Size(977, 427) + Me.grpEingabe.Size = New System.Drawing.Size(1300, 570) Me.grpEingabe.TabIndex = 3 Me.grpEingabe.TabStop = False Me.grpEingabe.Text = "Informationen eingeben" @@ -152,7 +187,7 @@ Partial Class frmEintragTvNew 'chkIsRecurring ' Me.chkIsRecurring.AutoSize = True - Me.chkIsRecurring.Location = New System.Drawing.Point(18, 302) + Me.chkIsRecurring.Location = New System.Drawing.Point(58, 439) Me.chkIsRecurring.Name = "chkIsRecurring" Me.chkIsRecurring.Size = New System.Drawing.Size(86, 17) Me.chkIsRecurring.TabIndex = 10 @@ -168,7 +203,7 @@ Partial Class frmEintragTvNew Me.grpWochentage.Controls.Add(Me.chkWednesday) Me.grpWochentage.Controls.Add(Me.chkTuesday) Me.grpWochentage.Controls.Add(Me.chkMonday) - Me.grpWochentage.Location = New System.Drawing.Point(20, 340) + Me.grpWochentage.Location = New System.Drawing.Point(60, 494) Me.grpWochentage.Name = "grpWochentage" Me.grpWochentage.Size = New System.Drawing.Size(763, 57) Me.grpWochentage.TabIndex = 11 @@ -248,7 +283,7 @@ Partial Class frmEintragTvNew 'dtpEndTime ' Me.dtpEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Time - Me.dtpEndTime.Location = New System.Drawing.Point(557, 245) + Me.dtpEndTime.Location = New System.Drawing.Point(597, 382) Me.dtpEndTime.Name = "dtpEndTime" Me.dtpEndTime.ShowCheckBox = True Me.dtpEndTime.ShowUpDown = True @@ -258,7 +293,7 @@ Partial Class frmEintragTvNew 'lblEndTime ' Me.lblEndTime.AutoSize = True - Me.lblEndTime.Location = New System.Drawing.Point(502, 248) + Me.lblEndTime.Location = New System.Drawing.Point(542, 385) Me.lblEndTime.Name = "lblEndTime" Me.lblEndTime.Size = New System.Drawing.Size(45, 13) Me.lblEndTime.TabIndex = 14 @@ -267,7 +302,7 @@ Partial Class frmEintragTvNew 'dtpStartTime ' Me.dtpStartTime.Format = System.Windows.Forms.DateTimePickerFormat.Time - Me.dtpStartTime.Location = New System.Drawing.Point(557, 204) + Me.dtpStartTime.Location = New System.Drawing.Point(597, 341) Me.dtpStartTime.Name = "dtpStartTime" Me.dtpStartTime.ShowCheckBox = True Me.dtpStartTime.ShowUpDown = True @@ -277,7 +312,7 @@ Partial Class frmEintragTvNew 'lblStartTime ' Me.lblStartTime.AutoSize = True - Me.lblStartTime.Location = New System.Drawing.Point(502, 205) + Me.lblStartTime.Location = New System.Drawing.Point(542, 342) Me.lblStartTime.Name = "lblStartTime" Me.lblStartTime.Size = New System.Drawing.Size(48, 13) Me.lblStartTime.TabIndex = 12 @@ -286,7 +321,7 @@ Partial Class frmEintragTvNew 'dtpEndDate ' Me.dtpEndDate.Format = System.Windows.Forms.DateTimePickerFormat.[Short] - Me.dtpEndDate.Location = New System.Drawing.Point(130, 245) + Me.dtpEndDate.Location = New System.Drawing.Point(170, 382) Me.dtpEndDate.Name = "dtpEndDate" Me.dtpEndDate.ShowCheckBox = True Me.dtpEndDate.Size = New System.Drawing.Size(201, 20) @@ -295,7 +330,7 @@ Partial Class frmEintragTvNew 'lblEndDate ' Me.lblEndDate.AutoSize = True - Me.lblEndDate.Location = New System.Drawing.Point(15, 248) + Me.lblEndDate.Location = New System.Drawing.Point(55, 385) Me.lblEndDate.Name = "lblEndDate" Me.lblEndDate.Size = New System.Drawing.Size(104, 13) Me.lblEndDate.TabIndex = 10 @@ -304,7 +339,7 @@ Partial Class frmEintragTvNew 'dtpStartDate ' Me.dtpStartDate.Format = System.Windows.Forms.DateTimePickerFormat.[Short] - Me.dtpStartDate.Location = New System.Drawing.Point(131, 205) + Me.dtpStartDate.Location = New System.Drawing.Point(171, 342) Me.dtpStartDate.Name = "dtpStartDate" Me.dtpStartDate.ShowCheckBox = True Me.dtpStartDate.Size = New System.Drawing.Size(200, 20) @@ -313,7 +348,7 @@ Partial Class frmEintragTvNew 'lblStartDate ' Me.lblStartDate.AutoSize = True - Me.lblStartDate.Location = New System.Drawing.Point(17, 205) + Me.lblStartDate.Location = New System.Drawing.Point(57, 342) Me.lblStartDate.Name = "lblStartDate" Me.lblStartDate.Size = New System.Drawing.Size(107, 13) Me.lblStartDate.TabIndex = 8 @@ -321,7 +356,7 @@ Partial Class frmEintragTvNew ' 'txtZeile3 ' - Me.txtZeile3.Location = New System.Drawing.Point(100, 120) + Me.txtZeile3.Location = New System.Drawing.Point(90, 242) Me.txtZeile3.Name = "txtZeile3" Me.txtZeile3.Size = New System.Drawing.Size(871, 20) Me.txtZeile3.TabIndex = 5 @@ -329,7 +364,7 @@ Partial Class frmEintragTvNew 'lblZeile3 ' Me.lblZeile3.AutoSize = True - Me.lblZeile3.Location = New System.Drawing.Point(42, 123) + Me.lblZeile3.Location = New System.Drawing.Point(42, 245) Me.lblZeile3.Name = "lblZeile3" Me.lblZeile3.Size = New System.Drawing.Size(42, 13) Me.lblZeile3.TabIndex = 6 @@ -337,7 +372,7 @@ Partial Class frmEintragTvNew ' 'txtZeile2 ' - Me.txtZeile2.Location = New System.Drawing.Point(100, 90) + Me.txtZeile2.Location = New System.Drawing.Point(90, 182) Me.txtZeile2.Name = "txtZeile2" Me.txtZeile2.Size = New System.Drawing.Size(871, 20) Me.txtZeile2.TabIndex = 4 @@ -345,18 +380,19 @@ Partial Class frmEintragTvNew 'lblZeile2 ' Me.lblZeile2.AutoSize = True - Me.lblZeile2.Location = New System.Drawing.Point(42, 93) + Me.lblZeile2.Location = New System.Drawing.Point(42, 185) Me.lblZeile2.Name = "lblZeile2" Me.lblZeile2.Size = New System.Drawing.Size(42, 13) Me.lblZeile2.TabIndex = 4 Me.lblZeile2.Text = "Zeile 2:" ' - 'txtZeile1 + 'rtbZeile1 ' - Me.txtZeile1.Location = New System.Drawing.Point(100, 60) - Me.txtZeile1.Name = "txtZeile1" - Me.txtZeile1.Size = New System.Drawing.Size(871, 20) - Me.txtZeile1.TabIndex = 3 + Me.rtbZeile1.Location = New System.Drawing.Point(100, 66) + Me.rtbZeile1.Name = "rtbZeile1" + Me.rtbZeile1.Size = New System.Drawing.Size(871, 80) + Me.rtbZeile1.TabIndex = 3 + Me.rtbZeile1.Text = "" ' 'lblZeile1 ' @@ -388,7 +424,7 @@ Partial Class frmEintragTvNew 'lblPosition ' Me.lblPosition.AutoSize = True - Me.lblPosition.Location = New System.Drawing.Point(42, 156) + Me.lblPosition.Location = New System.Drawing.Point(57, 412) Me.lblPosition.Name = "lblPosition" Me.lblPosition.Size = New System.Drawing.Size(47, 13) Me.lblPosition.TabIndex = 21 @@ -399,14 +435,104 @@ Partial Class frmEintragTvNew Me.cmbPosition.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.cmbPosition.FormattingEnabled = True Me.cmbPosition.Items.AddRange(New Object() {"Top", "Middle", "Bottom"}) - Me.cmbPosition.Location = New System.Drawing.Point(100, 152) + Me.cmbPosition.Location = New System.Drawing.Point(113, 409) Me.cmbPosition.Name = "cmbPosition" Me.cmbPosition.Size = New System.Drawing.Size(177, 21) Me.cmbPosition.TabIndex = 22 ' + 'btnBold + ' + Me.btnBold.Location = New System.Drawing.Point(60, 287) + Me.btnBold.Name = "btnBold" + Me.btnBold.Size = New System.Drawing.Size(30, 30) + Me.btnBold.TabIndex = 23 + Me.btnBold.Text = "B" + Me.btnBold.UseVisualStyleBackColor = True + ' + 'btnItalic + ' + Me.btnItalic.Location = New System.Drawing.Point(100, 287) + Me.btnItalic.Name = "btnItalic" + Me.btnItalic.Size = New System.Drawing.Size(30, 30) + Me.btnItalic.TabIndex = 24 + Me.btnItalic.Text = "I" + Me.btnItalic.UseVisualStyleBackColor = True + ' + 'btnUnderline + ' + Me.btnUnderline.Location = New System.Drawing.Point(140, 287) + Me.btnUnderline.Name = "btnUnderline" + Me.btnUnderline.Size = New System.Drawing.Size(30, 30) + Me.btnUnderline.TabIndex = 25 + Me.btnUnderline.Text = "U" + Me.btnUnderline.UseVisualStyleBackColor = True + ' + 'btnTextColor + ' + Me.btnTextColor.Location = New System.Drawing.Point(180, 287) + Me.btnTextColor.Name = "btnTextColor" + Me.btnTextColor.Size = New System.Drawing.Size(30, 30) + Me.btnTextColor.TabIndex = 26 + Me.btnTextColor.Text = "A" + Me.btnTextColor.UseVisualStyleBackColor = True + ' + 'btnBackColor + ' + Me.btnBackColor.Location = New System.Drawing.Point(220, 287) + Me.btnBackColor.Name = "btnBackColor" + Me.btnBackColor.Size = New System.Drawing.Size(30, 30) + Me.btnBackColor.TabIndex = 27 + Me.btnBackColor.Text = "BG" + Me.btnBackColor.UseVisualStyleBackColor = True + ' + 'btnAlignLeft + ' + Me.btnAlignLeft.Location = New System.Drawing.Point(260, 287) + Me.btnAlignLeft.Name = "btnAlignLeft" + Me.btnAlignLeft.Size = New System.Drawing.Size(30, 30) + Me.btnAlignLeft.TabIndex = 28 + Me.btnAlignLeft.Text = "L" + Me.btnAlignLeft.UseVisualStyleBackColor = True + ' + 'btnAlignCenter + ' + Me.btnAlignCenter.Location = New System.Drawing.Point(300, 287) + Me.btnAlignCenter.Name = "btnAlignCenter" + Me.btnAlignCenter.Size = New System.Drawing.Size(30, 30) + Me.btnAlignCenter.TabIndex = 29 + Me.btnAlignCenter.Text = "C" + Me.btnAlignCenter.UseVisualStyleBackColor = True + ' + 'btnAlignRight + ' + Me.btnAlignRight.Location = New System.Drawing.Point(340, 287) + Me.btnAlignRight.Name = "btnAlignRight" + Me.btnAlignRight.Size = New System.Drawing.Size(30, 30) + Me.btnAlignRight.TabIndex = 30 + Me.btnAlignRight.Text = "R" + Me.btnAlignRight.UseVisualStyleBackColor = True + ' + 'cmbFontFamily + ' + Me.cmbFontFamily.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList + Me.cmbFontFamily.FormattingEnabled = True + Me.cmbFontFamily.Location = New System.Drawing.Point(380, 292) + Me.cmbFontFamily.Name = "cmbFontFamily" + Me.cmbFontFamily.Size = New System.Drawing.Size(150, 21) + Me.cmbFontFamily.TabIndex = 31 + ' + 'cmbFontSize + ' + Me.cmbFontSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList + Me.cmbFontSize.FormattingEnabled = True + Me.cmbFontSize.Location = New System.Drawing.Point(540, 292) + Me.cmbFontSize.Name = "cmbFontSize" + Me.cmbFontSize.Size = New System.Drawing.Size(60, 21) + Me.cmbFontSize.TabIndex = 32 + ' 'btnSpeichern ' - Me.btnSpeichern.Location = New System.Drawing.Point(755, 708) + Me.btnSpeichern.Location = New System.Drawing.Point(1078, 862) Me.btnSpeichern.Name = "btnSpeichern" Me.btnSpeichern.Size = New System.Drawing.Size(75, 30) Me.btnSpeichern.TabIndex = 5 @@ -415,7 +541,7 @@ Partial Class frmEintragTvNew ' 'btnLoeschen ' - Me.btnLoeschen.Location = New System.Drawing.Point(836, 708) + Me.btnLoeschen.Location = New System.Drawing.Point(1159, 862) Me.btnLoeschen.Name = "btnLoeschen" Me.btnLoeschen.Size = New System.Drawing.Size(75, 30) Me.btnLoeschen.TabIndex = 6 @@ -424,7 +550,7 @@ Partial Class frmEintragTvNew ' 'btnAbbrechen ' - Me.btnAbbrechen.Location = New System.Drawing.Point(917, 708) + Me.btnAbbrechen.Location = New System.Drawing.Point(1240, 862) Me.btnAbbrechen.Name = "btnAbbrechen" Me.btnAbbrechen.Size = New System.Drawing.Size(75, 30) Me.btnAbbrechen.TabIndex = 7 @@ -443,7 +569,7 @@ Partial Class frmEintragTvNew ' 'frmEintragTvNew ' - Me.ClientSize = New System.Drawing.Size(1004, 750) + Me.ClientSize = New System.Drawing.Size(1337, 972) Me.Controls.Add(Me.chkShowInactive) Me.Controls.Add(Me.btnAbbrechen) Me.Controls.Add(Me.btnLoeschen) @@ -495,7 +621,6 @@ Partial Class frmEintragTvNew Friend WithEvents lblZeile3 As Label Friend WithEvents txtZeile2 As TextBox Friend WithEvents lblZeile2 As Label - Friend WithEvents txtZeile1 As TextBox Friend WithEvents lblZeile1 As Label Friend WithEvents cmbTvTextBezeichnungAuswahl As ComboBox Friend WithEvents lblBezeichnung As Label @@ -506,4 +631,6 @@ Partial Class frmEintragTvNew Friend WithEvents btnAbbrechen As Button Friend WithEvents chkShowInactive As CheckBox + + End Class diff --git a/Aviso/frmEintragTvNew.vb b/Aviso/frmEintragTvNew.vb index ea9d2c8..734edc2 100644 --- a/Aviso/frmEintragTvNew.vb +++ b/Aviso/frmEintragTvNew.vb @@ -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("") + + 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("") + End If + + ' Öffne neue Font-Tags + sb.Append("") + sb.Append("") + + 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("") + End Select + + ' Öffne neue Ausrichtung + Select Case alignment + Case HorizontalAlignment.Left + sb.Append("
") + Case HorizontalAlignment.Center + sb.Append("
") + Case HorizontalAlignment.Right + sb.Append("
") + 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("") + End If + + Select Case currentAlignment + Case HorizontalAlignment.Left, HorizontalAlignment.Center, HorizontalAlignment.Right + sb.Append("
") + End Select + + sb.Append("") + 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