Imports QHTML.frmQHTML
Imports QHTML.frmNew
Public Class frmTable
Public Structure Row
Dim Items As ArrayList
End Structure
Public Structure Cell
Dim Col, Row, Width As Int16
Dim Text As String
Dim VAlign As String
Dim Percentage As Boolean
End Structure
Public Cells As New ArrayList
Private Sub cmdRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRow.Click
TreeW.Nodes.Add("Riga " & TreeW.Nodes.Count + 1)
Dim R As Row
R.Items = New ArrayList
Cells.Add(R)
End Sub
Private Sub cmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBrowse.Click
If FOpen.ShowDialog = Windows.Forms.DialogResult.OK Then
txtIMG.Text = FOpen.FileName
End If
End Sub
Private Sub cmdCell_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCell.Click
Try
If Not TreeW.SelectedNode.Parent.Name.StartsWith("Riga") Then
MsgBox("E' necessario selezionare una riga prima di inserire la cella!", MsgBoxStyle.Exclamation)
Exit Sub
End If
Catch ex As System.NullReferenceException
End Try
TreeW.SelectedNode.Nodes.Add(txtText.Text)
Dim R, C, P As Int16
Dim Per As Boolean
Dim V As String
R = nudColSpan.Value
C = nudRowSpan.Value
V = cmbValign.SelectedItem
P = nudCWidth.Value
Per = chbPercentage.Checked
Dim Cs As Cell
Cs.Col = C
Cs.Row = R
Cs.Text = txtText.Text
Cs.VAlign = V
Cs.Width = P
Cs.Percentage = Per
nudColSpan.Value = 0
nudRowSpan.Value = 0
cmbValign.SelectedIndex = 0
txtText.Text = ""
Cells.Item(TreeW.SelectedNode.Index).Items.Add(Cs)
End Sub
Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
Dim Cs As Cell
Dim Rw As Row
Dim R As Int32 = 0
Dim Result As String = "<!--Tabella:-->" + vbCrLf + " <table"
Result += " width=" + Quote & nudWidth.Value & Quote
Result += " height=" + Quote & nudHeight.Value & Quote
Result += " border=" + Quote & nudBorder.Value & Quote
Result += " cellspacing=" + Quote & nudSpacing.Value & Quote
Result += " cellpadding=" + Quote & nudPadding.Value & Quote
Result += " bgcolor=" + Quote + cmbColor.SelectedItem + Quote
If txtIMG.Text <> Nothing Then
If Not IsUrl(txtIMG.Text) Then
txtIMG.Text = LocalToFile(txtIMG.Text)
End If
End If
Result += " background=" + Quote + txtIMG.Text + Quote + ">" + vbCrLf
Result += " <caption>" + txtTitle.Text + "</caption>" + vbCrLf
Result += " <tbody>" + vbCrLf
For Each Rw In Cells
Result += " <tr>" + vbCrLf
For Each Cs In Cells.Item(R).Items
Result += " <td rowspan=" + Quote & Cs.Row & Quote + " colspan=" + Quote & Cs.Col & Quote
Result += " valign=" + Quote + Cs.VAlign + Quote
Result += " width=" + Quote & Cs.Width
If Cs.Percentage Then
Result += "%"
End If
Result += Quote + ">" + vbCrLf
Result += " " + Cs.Text + vbCrLf
Result += " </td>" + vbCrLf
Next
Result += " </tr>" + vbCrLf
R += 1
Next
Result += " </tbody>" + vbCrLf + " </table>" + vbCrLf + " <!--Fine tabella-->"
InsertTAG(Result)
Me.Close()
End Sub
Private Sub chbPercentage_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chbPercentage.CheckedChanged
If chbPercentage.Checked Then
nudCWidth.Maximum = 100
Else
nudCWidth.Maximum = 10000
End If
End Sub
End Class