Files
ADMIN/UID/Homepage/frmHomepageWartungNew.vb
2019-08-08 12:44:50 +02:00

312 lines
11 KiB
VB.net

Imports FastColoredTextBoxNS
Imports System.IO
Public Class frmHomepageWartungNew
Private DB As New cDBHomepage
Private DBOpt As New cOptionenDAL
Dim blocks As New List(Of cBlock)
Private margin_top As Integer = 20
Private margin_left As Integer = 20
Private top_value As Integer = 0
Private left_value As Integer = 0
Private rowmaxheight As Integer = 0
Private screenwidth As Integer = 1200
Dim WithEvents fctbHTML As New FastColoredTextBox
Dim hp_content As hp_content
Dim hp_test '????????????????????????????????
Dim laenderkuerzel As String = "de"
Dim menueId As Integer = 1
Private Sub frmHomepageWartungNew_KeyDown(sender As Object, e As KeyEventArgs) Handles fctbHTML.KeyDown
'MsgBox("KKK" & e.KeyCode)
If e.KeyCode = Keys.S AndAlso e.Modifiers = Keys.Control Then
Button1.PerformClick()
End If
End Sub
Private Sub frmHomepageWartungNew_Load(sender As Object, e As EventArgs) Handles Me.Load
Panel1.Controls.Add(fctbHTML)
fctbHTML.Dock = DockStyle.Fill
initFctb()
initCboIMG()
' menueHomepage.Items.Add("--> +")
ComboBox2.Items.Clear()
ComboBox2.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Deutsch", "de"))
ComboBox2.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Englisch", "en"))
ComboBox2.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Türkisch", "tr"))
ComboBox2.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Rumänisch", "ro"))
ComboBox2.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Bulgarisch", "bg"))
ComboBox2.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Serbisch", "yu"))
initHomepage()
End Sub
Sub initMenue()
menueHomepage.Items.Clear()
Dim nav As List(Of cNavigation) = DB.qry_menu_tags("de")
For Each n In nav
Dim item As New ToolStripMenuItem(n.bezeichnung)
item.Name = n.id
For Each n2 In n.subnavigation
Dim i As New ToolStripMenuItem(n2.bezeichnung)
i.Name = n2.id
For Each n3 In n2.subnavigation
Dim ii As New ToolStripMenuItem(n3.bezeichnung)
i.DropDownItems.Add(ii)
ii.Name = n3.id
AddHandler ii.Click, AddressOf itemclick
Next
AddHandler i.Click, AddressOf itemclick
item.DropDownItems.Add(i)
'Eigenes bearbeiten
' Dim edititem2 As New ToolStripMenuItem("--> """ & n2.bezeichnung & """ bearbeiten")
' i.DropDownItems.Add(edititem2)
' edititem2.Name = n2.id
' AddHandler edititem2.Click, AddressOf itemclick
menueHomepage.Items.Add(item)
'hinzufügen
' Dim additem2 As New ToolStripMenuItem("--> +")
' i.DropDownItems.Add(additem2)
' additem2.Name = n2.id
' AddHandler additem2.Click, AddressOf itemclickPLUS
menueHomepage.Items.Add(item)
Next
'Eigenes bearbeiten
Dim edititem As New ToolStripMenuItem("--> """ & n.bezeichnung & """ bearbeiten")
item.DropDownItems.Add(edititem)
edititem.Name = n.id
AddHandler edititem.Click, AddressOf itemclick
menueHomepage.Items.Add(item)
'hinzufügen
'Dim additem As New ToolStripMenuItem("--> +")
'item.DropDownItems.Add(additem)
' additem.Name = n.id
' AddHandler additem.Click, AddressOf itemclickPLUS
menueHomepage.Items.Add(item)
Next
End Sub
Private Sub itemclick(sender As Object, e As EventArgs)
menueId = sender.name
initHomepage()
End Sub
Private Sub itemclickPLUS(sender As Object, e As EventArgs)
Exit Sub
Dim title As String = InputBox("Bitte geben Sie den deutschen Menü-Titel an:")
If title <> "" Then
initHomepage()
Else
MsgBox("Der Titel darf nicht leer sein!")
End If
End Sub
Private Sub addClick(sender As Object, e As EventArgs)
If sender.name.ToString.Contains("addHp_") Then
Dim id As Integer = CInt(sender.name.ToString.Replace("addHp_", ""))
MsgBox("ADD: " & id)
End If
End Sub
Private Sub delClick(sender As Object, e As EventArgs)
If sender.name.ToString.Contains("delHp_") Then
Dim id As Integer = CInt(sender.name.ToString.Replace("delHp_", ""))
MsgBox("DEL: " & id)
End If
End Sub
Sub initHomepage()
initMenue()
Try
hp_content = DB.qry_contentNew(menueId, laenderkuerzel)
If hp_content Is Nothing Then
hp_content = New hp_content
hp_content.hp_content = ""
'hp_content.hp_id = menueId
hp_content.hp_id = -1
End If
Catch ex As Exception
MsgBox("ERR")
End Try
fctbHTML.Text = hp_content.hp_content
txtMenueimgPath.Text = hp_content.hp_imgPath
txtMenueName.Text = hp_content.hp_title
txtMenueSlogan.Text = hp_content.hp_slogan
Try
If hp_content.hp_imgPath <> "" Then
pictxtMenueImg.Image = Image.FromFile(hp_test & "" & hp_content.hp_imgPath)
End If
Catch ex As Exception
End Try
Button3.Enabled = False 'del
Button4.Enabled = False 'unter
If hp_content.hp_instance <> "" Then
If hp_content.hp_instance > 0 Then Button3.Enabled = True
If hp_content.hp_instance < 2 Then Button4.Enabled = True
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
hp_content.hp_content = fctbHTML.Text
hp_content.hp_imgPath = txtMenueimgPath.Text
hp_content.hp_title = txtMenueName.Text
hp_content.hp_slogan = txtMenueSlogan.Text
If hp_content.hp_id >= 0 Then
DB.update_HPContentNew(hp_content, laenderkuerzel)
Else
End If
initHomepage()
End Sub
Sub initFctb()
Me.fctbHTML.AutoIndent = False
Me.fctbHTML.AutoScrollMinSize = New Size(0, 15)
Me.fctbHTML.BackBrush = Nothing
Me.fctbHTML.Cursor = Cursors.IBeam
Me.fctbHTML.DelayedEventsInterval = 500
Me.fctbHTML.DisabledColor = Color.FromArgb(100, 180, 180, 180)
Me.fctbHTML.Dock = DockStyle.Fill
Me.fctbHTML.Font = New Font("Consolas", 9.75F)
Me.fctbHTML.IndentBackColor = Color.FromArgb(50, 255, 255, 255)
Me.fctbHTML.LeftBracket = "("
Me.fctbHTML.LeftPadding = 15
Me.fctbHTML.Location = New Point(0, 0)
Me.fctbHTML.Name = "fctbHTML"
Me.fctbHTML.Paddings = New Padding(0)
Me.fctbHTML.RightBracket = ")"
Me.fctbHTML.SelectionColor = Color.FromArgb(50, 0, 0, 255)
Me.fctbHTML.Size = New Size(447, 262)
Me.fctbHTML.TabIndex = 0
Me.fctbHTML.WordWrap = True
' AddHandler Me.fctbHTML.SelectionChangedDelayed, New EventHandler(AddressOf Me.fctbHTML_SelectionChangedDelayed)
' AddHandler Me.fctbHTML.VisualMarkerClick, New EventHandler(Of VisualMarkerEventArgs)(AddressOf Me.fctbHTML_VisualMarkerClick)
' AddHandler Me.fctbHTML.PaintLine, New EventHandler(Of PaintLineEventArgs)(AddressOf Me.fctbHTML_PaintLine)
' AddHandler Me.fctbHTML.Resize, New EventHandler(AddressOf Me.fctbHTML_Resize)
End Sub
Sub tb_TextChangedDelayed(sender As Object, e As TextChangedEventArgs) Handles fctbHTML.TextChangedDelayed
Dim tb As FastColoredTextBox = sender
'highlight html
tb.SyntaxHighlighter.InitStyleSchema(Language.HTML)
tb.SyntaxHighlighter.HTMLSyntaxHighlight(tb.Range)
tb.Range.ClearFoldingMarkers()
'find PHP fragments
' foreach(var r in tb.GetRanges(@"<\?php.*?\?>", RegexOptions.Singleline))
For Each r In tb.GetRanges("@<\?php.*?\?>", 16)
' //remove HTML highlighting from this fragment
r.ClearStyle(StyleIndex.All)
' //do PHP highlighting
tb.SyntaxHighlighter.InitStyleSchema(Language.PHP)
tb.SyntaxHighlighter.PHPSyntaxHighlight(r)
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'FileDialog()
Try
Dim ofd As New OpenFileDialog
ofd.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
' Dim file As File = ""
Dim myValue = InputBox("Bitte Name eingeben (mit Endung)", "FileName", cut_file(ofd.FileName))
If myValue <> "" Then
FileCopy(ofd.FileName, hp_test & "images\" & myValue)
End If
End If
initCboIMG()
Catch ex As Exception
MsgBox("Fehler beim speichern des Bildes")
End Try
End Sub
Sub initCboIMG()
ComboBox1.Items.Clear()
For Each file As String In IO.Directory.GetFiles(hp_test & "images\") ' Ermittelt alle Dateien des Ordners
ComboBox1.Items.Add(cut_file(file))
Next
End Sub
Private Function cut_file(ByVal file As String) As String ' Funktion zum Entfernen der Backslashs / Ordner While file.Contains("\") file = file.Remove(0, 1) End While Return file End Function
While file.Contains("\")
file = file.Remove(0, 1)
End While
Return file
End Function
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
My.Computer.Clipboard.SetText("images/" & sender.Text)
PictureBox1.Image = Image.FromFile(hp_test & "images\" & sender.text)
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
laenderkuerzel = DirectCast(ComboBox2.SelectedItem, VERAG_PROG_ALLGEMEIN.MyListItem).Value
initHomepage()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If vbYes = MsgBox("Möchten Sie wirklich diese Seite und allen Sprachen löschen?" & vbNewLine & "'" & hp_content.hp_title & "'", vbYesNoCancel) Then 'alle Unterseiten in
DB.deleteHpMenueAndContent(hp_content.hp_id)
End If
menueId = 1
initHomepage()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim title = InputBox("Bitte geben Sie den deutschen Menü-Titel an:")
If title <> "" Then
menueId = DB.insert_HPContentNew(hp_content, laenderkuerzel, title, hp_content.hp_id, hp_content.hp_instance)
initHomepage()
Else
MsgBox("Der Titel darf nicht leer sein!")
End If
End Sub
End Class
Public Class hp_content
Property hp_id As Integer
Property hp_title As String
Property hp_content As String
Property hp_instance As String
Property hp_slogan As String
Property hp_imgPath As String
Property hp_refIdToUpperMenue As String
End Class