Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
QHTML 2.0 - frmTable.vb

frmTable.vb

Caricato da: Totem
Scarica il programma completo

  1. Imports QHTML.frmQHTML
  2. Imports QHTML.frmNew
  3. Public Class frmTable
  4.     Public Structure Row
  5.         Dim Items As ArrayList
  6.     End Structure
  7.     Public Structure Cell
  8.         Dim Col, Row, Width As Int16
  9.         Dim Text As String
  10.         Dim VAlign As String
  11.         Dim Percentage As Boolean
  12.     End Structure
  13.     Public Cells As New ArrayList
  14.     Private Sub cmdRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRow.Click
  15.         TreeW.Nodes.Add("Riga " & TreeW.Nodes.Count + 1)
  16.  
  17.         Dim R As Row
  18.         R.Items = New ArrayList
  19.  
  20.         Cells.Add(R)
  21.     End Sub
  22.     Private Sub cmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBrowse.Click
  23.         If FOpen.ShowDialog = Windows.Forms.DialogResult.OK Then
  24.             txtIMG.Text = FOpen.FileName
  25.         End If
  26.     End Sub
  27.     Private Sub cmdCell_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCell.Click
  28.         Try
  29.             If Not TreeW.SelectedNode.Parent.Name.StartsWith("Riga") Then
  30.                 MsgBox("E' necessario selezionare una riga prima di inserire la cella!", MsgBoxStyle.Exclamation)
  31.                 Exit Sub
  32.             End If
  33.         Catch ex As System.NullReferenceException
  34.         End Try
  35.  
  36.         TreeW.SelectedNode.Nodes.Add(txtText.Text)
  37.  
  38.         Dim R, C, P As Int16
  39.         Dim Per As Boolean
  40.         Dim V As String
  41.         R = nudColSpan.Value
  42.         C = nudRowSpan.Value
  43.         V = cmbValign.SelectedItem
  44.         P = nudCWidth.Value
  45.         Per = chbPercentage.Checked
  46.  
  47.         Dim Cs As Cell
  48.         Cs.Col = C
  49.         Cs.Row = R
  50.         Cs.Text = txtText.Text
  51.         Cs.VAlign = V
  52.         Cs.Width = P
  53.         Cs.Percentage = Per
  54.  
  55.         nudColSpan.Value = 0
  56.         nudRowSpan.Value = 0
  57.         cmbValign.SelectedIndex = 0
  58.         txtText.Text = ""
  59.  
  60.         Cells.Item(TreeW.SelectedNode.Index).Items.Add(Cs)
  61.     End Sub
  62.     Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
  63.         Dim Cs As Cell
  64.         Dim Rw As Row
  65.         Dim R As Int32 = 0
  66.         Dim Result As String = "<!--Tabella:-->" + vbCrLf + "  <table"
  67.  
  68.         Result += " width=" + Quote & nudWidth.Value & Quote
  69.         Result += " height=" + Quote & nudHeight.Value & Quote
  70.         Result += " border=" + Quote & nudBorder.Value & Quote
  71.         Result += " cellspacing=" + Quote & nudSpacing.Value & Quote
  72.         Result += " cellpadding=" + Quote & nudPadding.Value & Quote
  73.         Result += " bgcolor=" + Quote + cmbColor.SelectedItem + Quote
  74.  
  75.         If txtIMG.Text <> Nothing Then
  76.             If Not IsUrl(txtIMG.Text) Then
  77.                 txtIMG.Text = LocalToFile(txtIMG.Text)
  78.             End If
  79.         End If
  80.         Result += " background=" + Quote + txtIMG.Text + Quote + ">" + vbCrLf
  81.  
  82.         Result += "  <caption>" + txtTitle.Text + "</caption>" + vbCrLf
  83.         Result += "  <tbody>" + vbCrLf
  84.  
  85.         For Each Rw In Cells
  86.             Result += "  <tr>" + vbCrLf
  87.             For Each Cs In Cells.Item(R).Items
  88.                 Result += "    <td rowspan=" + Quote & Cs.Row & Quote + " colspan=" + Quote & Cs.Col & Quote
  89.                 Result += " valign=" + Quote + Cs.VAlign + Quote
  90.                 Result += " width=" + Quote & Cs.Width
  91.                 If Cs.Percentage Then
  92.                     Result += "%"
  93.                 End If
  94.                 Result += Quote + ">" + vbCrLf
  95.                 Result += "    " + Cs.Text + vbCrLf
  96.                 Result += "    </td>" + vbCrLf
  97.             Next
  98.             Result += "  </tr>" + vbCrLf
  99.             R += 1
  100.         Next
  101.  
  102.         Result += "  </tbody>" + vbCrLf + "  </table>" + vbCrLf + "  <!--Fine tabella-->"
  103.  
  104.         InsertTAG(Result)
  105.  
  106.         Me.Close()
  107.     End Sub
  108.     Private Sub chbPercentage_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chbPercentage.CheckedChanged
  109.         If chbPercentage.Checked Then
  110.             nudCWidth.Maximum = 100
  111.         Else
  112.             nudCWidth.Maximum = 10000
  113.         End If
  114.     End Sub
  115. End Class