Html editor v1.0- source

16/10/2009 09:37

[Information]

- The software is also available at a1vbcode.com for download.

-Created in Vb.net 2005.

[Source Code]

{Main form}

Imports System.IO
Imports System.Drawing.Printing
Imports System.Drawing.size
Public Class Form1
    Dim B As New ArrayList
    Dim proc As New System.Diagnostics.Process()

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Opacity = 0.9
        ToolStripProgressBar1.Visible = False
        Dim w As New RichTextBox
        Dim t As New TabPage
        Dim n As Integer
        t.Controls.Add(w)
        B.Add(w)
        w.Dock = DockStyle.Fill
        n = TabControl1.TabPages.Count + 1
        t.Text = "[" & n & "]" & " Html Tabpage Document"
        TabControl1.Controls.Add(t)
        TabControl1.SelectedTab = t
        w.SelectionFont = New Font("Times New Roman", 12, FontStyle.Bold)
        w.BorderStyle = BorderStyle.None
    End Sub
    Sub startdebug()
        debug.Show()
        Me.WindowState = FormWindowState.Normal
        Dim file As String = Application.StartupPath & "debug.html"
        Dim dataPath As String = Path.Combine(Application.StartupPath, file)
        Dim output As New StreamWriter(New FileStream(dataPath, FileMode.Create))
        output.Write(CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Text())
        output.Close()
        debug.WebBrowser1.Navigate(dataPath)
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ToolStripProgressBar1.Maximum = 100
        ToolStripProgressBar1.Visible = True
        If ToolStripProgressBar1.Value <> ToolStripProgressBar1.Maximum Then
            ToolStripProgressBar1.Value += 20
        Else
            ToolStripProgressBar1.Value = 0
            Timer1.Enabled = False
            ToolStripProgressBar1.Visible = False
            Call startdebug()
            ToolStripProgressBar1.Visible = False
        End If
    End Sub


    Private Sub ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem5.Click
        Timer1.Enabled = True
    End Sub

    Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
        Dim x As New Form1
        x.Show()
    End Sub

    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
        Dim w As New RichTextBox
        Dim t As New TabPage
        Dim n As Integer
        t.Controls.Add(w)
        B.Add(w)
        w.Dock = DockStyle.Fill
        n = TabControl1.TabPages.Count + 1
        t.Text = "[" & n & "]" & " Html Tabpage Document"
        TabControl1.Controls.Add(t)
        TabControl1.SelectedTab = t
        w.SelectionFont = New Font("Times New Roman", 12, FontStyle.Bold)
        w.BorderStyle = BorderStyle.None
    End Sub

    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        If TabControl1.TabCount = 1 Then
            MsgBox("Default Page Cannot be Deleted!", vbCritical, "Tab Editor")

        Else
            Me.TabControl1.TabPages.RemoveAt(1)
        End If
    End Sub

    Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click
        Dim o As String
        Using ofd As New OpenFileDialog()
            ofd.Filter = "htm (*.htm)|*.htm|html (*.html)|*.html|All Files (*.*)|*.*"
            If (ofd.ShowDialog(Me) = Windows.Forms.DialogResult.OK) Then
                o = ofd.FileName
                CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).LoadFile(o, RichTextBoxStreamType.PlainText)

            End If
        End Using
    End Sub

    Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click
        Dim o As String
        Using ofd As New SaveFileDialog()
            ofd.Filter = "htm (*.htm)|*.htm|html (*.html)|*.html|All Files (*.*)|*.*"
            If (ofd.ShowDialog(Me) = Windows.Forms.DialogResult.OK) Then
                o = ofd.FileName
                CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).SaveFile(o, RichTextBoxStreamType.PlainText)

            End If
        End Using
    End Sub

    Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
        Dim docPrn As New PrintDocument()
        docPrn.DocumentName = CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Text
        PageSetupDialog1.Document = docPrn
        PageSetupDialog1.ShowDialog()
    End Sub

    Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
        PrintDialog1.AllowPrintToFile = True
        Dim docPrn As New PrintDocument()
        docPrn.DocumentName = CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Text
        PrintDialog1.Document = docPrn
        If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Try
                docPrn.Print()
            Catch
            End Try
        End If
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Application.Restart()
    End Sub

    Private Sub EndToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndToolStripMenuItem.Click
        End
    End Sub

    Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Copy()
    End Sub

    Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Cut()
    End Sub

    Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Paste()
    End Sub

    Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).SelectedText = ""
    End Sub

    Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).SelectAll()
    End Sub

    Private Sub TimeAndDateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimeAndDateToolStripMenuItem.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).SelectedText = Date.Now
    End Sub

    Private Sub VisitMyWebsiteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VisitMyWebsiteToolStripMenuItem.Click
        proc = Process.Start("firefox", "frameharley.multiply.com")
    End Sub
    Sub help()
        MsgBox("Simple Html Editor created by Dennis Balinhawang")
    End Sub
    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        Call help()

    End Sub

    Private Sub OpenToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripButton.Click
        Dim o As String
        Using ofd As New OpenFileDialog()
            ofd.Filter = "htm (*.htm)|*.htm|html (*.html)|*.html|All Files (*.*)|*.*"
            If (ofd.ShowDialog(Me) = Windows.Forms.DialogResult.OK) Then
                o = ofd.FileName
                CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).LoadFile(o, RichTextBoxStreamType.PlainText)

            End If
        End Using
    End Sub

    Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
        Dim o As String
        Using ofd As New SaveFileDialog()
            ofd.Filter = "htm (*.htm)|*.htm|html (*.html)|*.html|All Files (*.*)|*.*"
            If (ofd.ShowDialog(Me) = Windows.Forms.DialogResult.OK) Then
                o = ofd.FileName
                CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).SaveFile(o, RichTextBoxStreamType.PlainText)

            End If
        End Using
    End Sub

    Private Sub PrintToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripButton.Click
        PrintDialog1.AllowPrintToFile = True
        Dim docPrn As New PrintDocument()
        docPrn.DocumentName = CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Text
        PrintDialog1.Document = docPrn
        If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Try
                docPrn.Print()
            Catch
            End Try
        End If
    End Sub

    Private Sub CutToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripButton.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Cut()
    End Sub

    Private Sub CopyToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripButton.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Copy()
    End Sub

    Private Sub PasteToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripButton.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Paste()
    End Sub

    Private Sub HelpToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripButton.Click
        Call help()
    End Sub

  
    Private Sub NotepadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NotepadToolStripMenuItem.Click
        proc = Process.Start("notepad")
    End Sub

    Private Sub WordpadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WordpadToolStripMenuItem.Click
        proc = Process.Start("wordpad")
    End Sub

    Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click
        run.Show()
    End Sub

    Private Sub NewToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripButton.Click
        CType(TabControl1.SelectedTab.Controls.Item(0), RichTextBox).Clear()
    End Sub
End Class

{run form}

Public Class run
    Dim proc As New System.Diagnostics.Process()
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ComboBox1.Text = "" Then
            MsgBox("Empty Something", vbInformation, "Kangaroo Notice")
        Else
            If RadioButton1.Checked = True Then
                Me.Hide()
                Form1.Show()
                proc = Process.Start(ComboBox1.Text)
                ComboBox1.Items.Add(ComboBox1.Text)
            ElseIf RadioButton2.Checked = True Then
                proc = Process.Start(ComboBox1.Text)
                ComboBox1.Items.Add(ComboBox1.Text)
            End If
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Hide()
        Form1.Show()
    End Sub

    Private Sub run_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RadioButton1.Checked = True
        Me.Opacity = 0.9
    End Sub
End Class

 

Back