MhtBuilder_demo.zip


Zip contents | Download all

Imports System.IO
Imports System.Text.RegularExpressions

''' <remarks>
'''   Jeff Atwood
'''   http://www.codinghorror.com/
''' </remarks>
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        TextEncodingComboBox.SelectedIndex = 0
        MemoryRadioButton.Checked = True
        BrowserIdTextBox.Text = _mht.BrowserIdString
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
    Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage3 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage4 As System.Windows.Forms.TabPage
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents CompleteFileTextBox As System.Windows.Forms.TextBox
    Friend WithEvents HtmlFileTextBox As System.Windows.Forms.TextBox
    Friend WithEvents TextFileTextBox As System.Windows.Forms.TextBox
    Friend WithEvents ViewCompleteButton As System.Windows.Forms.Button
    Friend WithEvents ViewHtmlButton As System.Windows.Forms.Button
    Friend WithEvents SaveHtmlButton As System.Windows.Forms.Button
    Friend WithEvents ViewTextButton As System.Windows.Forms.Button
    Friend WithEvents SaveTextButton As System.Windows.Forms.Button
    Friend WithEvents BuildFileButton As System.Windows.Forms.Button
    Friend WithEvents IFrameCheckBox As System.Windows.Forms.CheckBox
    Friend WithEvents ScriptCheckBox As System.Windows.Forms.CheckBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents TextEncodingComboBox As System.Windows.Forms.ComboBox
    Friend WithEvents TabControl2 As System.Windows.Forms.TabControl
    Friend WithEvents TabPage5 As System.Windows.Forms.TabPage
    Friend WithEvents TabPage6 As System.Windows.Forms.TabPage
    Friend WithEvents ViewMhtButton As System.Windows.Forms.Button
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents MhtFileTextBox As System.Windows.Forms.TextBox
    Friend WithEvents BuildMhtButton As System.Windows.Forms.Button
    Friend WithEvents MemoryRadioButton As System.Windows.Forms.RadioButton
    Friend WithEvents DiskTempRadioButton As System.Windows.Forms.RadioButton
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents DiskPermRadioButton As System.Windows.Forms.RadioButton
    Friend WithEvents BuildMhtMemoryButton As System.Windows.Forms.Button
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents ViewUrlButton As System.Windows.Forms.Button
    Friend WithEvents UrlTextBox As System.Windows.Forms.TextBox
    Friend WithEvents ProxyAuthCheckBox As System.Windows.Forms.CheckBox
    Friend WithEvents AuthCheckBox As System.Windows.Forms.CheckBox
    Friend WithEvents ProxyUrlTextBox As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents ProxyUserTextBox As System.Windows.Forms.TextBox
    Friend WithEvents ProxyPasswordTextBox As System.Windows.Forms.TextBox
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents Label11 As System.Windows.Forms.Label
    Friend WithEvents AuthPasswordTextBox As System.Windows.Forms.TextBox
    Friend WithEvents AuthUserTextBox As System.Windows.Forms.TextBox
    Friend WithEvents Label12 As System.Windows.Forms.Label
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Friend WithEvents RecursionCheckBox As System.Windows.Forms.CheckBox
    Friend WithEvents BrowserIdTextBox As System.Windows.Forms.TextBox
    Friend WithEvents Label14 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.TabControl1 = New System.Windows.Forms.TabControl
        Me.TabPage1 = New System.Windows.Forms.TabPage
        Me.TabControl2 = New System.Windows.Forms.TabControl
        Me.TabPage5 = New System.Windows.Forms.TabPage
        Me.ViewMhtButton = New System.Windows.Forms.Button
        Me.Label2 = New System.Windows.Forms.Label
        Me.MhtFileTextBox = New System.Windows.Forms.TextBox
        Me.BuildMhtButton = New System.Windows.Forms.Button
        Me.MemoryRadioButton = New System.Windows.Forms.RadioButton
        Me.DiskTempRadioButton = New System.Windows.Forms.RadioButton
        Me.Label6 = New System.Windows.Forms.Label
        Me.DiskPermRadioButton = New System.Windows.Forms.RadioButton
        Me.TabPage6 = New System.Windows.Forms.TabPage
        Me.BuildMhtMemoryButton = New System.Windows.Forms.Button
        Me.TabPage3 = New System.Windows.Forms.TabPage
        Me.ViewHtmlButton = New System.Windows.Forms.Button
        Me.Label4 = New System.Windows.Forms.Label
        Me.HtmlFileTextBox = New System.Windows.Forms.TextBox
        Me.SaveHtmlButton = New System.Windows.Forms.Button
        Me.TabPage2 = New System.Windows.Forms.TabPage
        Me.ViewCompleteButton = New System.Windows.Forms.Button
        Me.BuildFileButton = New System.Windows.Forms.Button
        Me.Label3 = New System.Windows.Forms.Label
        Me.CompleteFileTextBox = New System.Windows.Forms.TextBox
        Me.TabPage4 = New System.Windows.Forms.TabPage
        Me.ViewTextButton = New System.Windows.Forms.Button
        Me.Label5 = New System.Windows.Forms.Label
        Me.TextFileTextBox = New System.Windows.Forms.TextBox
        Me.SaveTextButton = New System.Windows.Forms.Button
        Me.IFrameCheckBox = New System.Windows.Forms.CheckBox
        Me.ScriptCheckBox = New System.Windows.Forms.CheckBox
        Me.Label7 = New System.Windows.Forms.Label
        Me.TextEncodingComboBox = New System.Windows.Forms.ComboBox
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Label13 = New System.Windows.Forms.Label
        Me.Label12 = New System.Windows.Forms.Label
        Me.Label10 = New System.Windows.Forms.Label
        Me.Label11 = New System.Windows.Forms.Label
        Me.AuthPasswordTextBox = New System.Windows.Forms.TextBox
        Me.AuthUserTextBox = New System.Windows.Forms.TextBox
        Me.Label9 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.ProxyPasswordTextBox = New System.Windows.Forms.TextBox
        Me.ProxyUserTextBox = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.ProxyUrlTextBox = New System.Windows.Forms.TextBox
        Me.ProxyAuthCheckBox = New System.Windows.Forms.CheckBox
        Me.AuthCheckBox = New System.Windows.Forms.CheckBox
        Me.ViewUrlButton = New System.Windows.Forms.Button
        Me.UrlTextBox = New System.Windows.Forms.TextBox
        Me.RecursionCheckBox = New System.Windows.Forms.CheckBox
        Me.BrowserIdTextBox = New System.Windows.Forms.TextBox
        Me.Label14 = New System.Windows.Forms.Label
        Me.TabControl1.SuspendLayout()
        Me.TabPage1.SuspendLayout()
        Me.TabControl2.SuspendLayout()
        Me.TabPage5.SuspendLayout()
        Me.TabPage6.SuspendLayout()
        Me.TabPage3.SuspendLayout()
        Me.TabPage2.SuspendLayout()
        Me.TabPage4.SuspendLayout()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(216, 492)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 9
        Me.Button1.Text = "Button1"
        '
        'TabControl1
        '
        Me.TabControl1.Controls.Add(Me.TabPage1)
        Me.TabControl1.Controls.Add(Me.TabPage3)
        Me.TabControl1.Controls.Add(Me.TabPage2)
        Me.TabControl1.Controls.Add(Me.TabPage4)
        Me.TabControl1.Location = New System.Drawing.Point(12, 368)
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.Size = New System.Drawing.Size(440, 176)
        Me.TabControl1.TabIndex = 12
        '
        'TabPage1
        '
        Me.TabPage1.Controls.Add(Me.TabControl2)
        Me.TabPage1.Location = New System.Drawing.Point(4, 22)
        Me.TabPage1.Name = "TabPage1"
        Me.TabPage1.Size = New System.Drawing.Size(432, 150)
        Me.TabPage1.TabIndex = 0
        Me.TabPage1.Text = "Single File Web Archive"
        '
        'TabControl2
        '
        Me.TabControl2.Appearance = System.Windows.Forms.TabAppearance.Buttons
        Me.TabControl2.Controls.Add(Me.TabPage5)
        Me.TabControl2.Controls.Add(Me.TabPage6)
        Me.TabControl2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.TabControl2.Location = New System.Drawing.Point(0, 0)
        Me.TabControl2.Name = "TabControl2"
        Me.TabControl2.SelectedIndex = 0
        Me.TabControl2.Size = New System.Drawing.Size(432, 150)
        Me.TabControl2.TabIndex = 30
        '
        'TabPage5
        '
        Me.TabPage5.Controls.Add(Me.ViewMhtButton)
        Me.TabPage5.Controls.Add(Me.Label2)
        Me.TabPage5.Controls.Add(Me.MhtFileTextBox)
        Me.TabPage5.Controls.Add(Me.BuildMhtButton)
        Me.TabPage5.Controls.Add(Me.MemoryRadioButton)
        Me.TabPage5.Controls.Add(Me.DiskTempRadioButton)
        Me.TabPage5.Controls.Add(Me.Label6)
        Me.TabPage5.Controls.Add(Me.DiskPermRadioButton)
        Me.TabPage5.Location = New System.Drawing.Point(4, 25)
        Me.TabPage5.Name = "TabPage5"
        Me.TabPage5.Size = New System.Drawing.Size(424, 121)
        Me.TabPage5.TabIndex = 0
        Me.TabPage5.Text = "On Disk"
        '
        'ViewMhtButton
        '
        Me.ViewMhtButton.Enabled = False
        Me.ViewMhtButton.Location = New System.Drawing.Point(352, 88)
        Me.ViewMhtButton.Name = "ViewMhtButton"
        Me.ViewMhtButton.Size = New System.Drawing.Size(60, 23)
        Me.ViewMhtButton.TabIndex = 32
        Me.ViewMhtButton.Text = "View"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(0, 4)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(266, 16)
        Me.Label2.TabIndex = 31
        Me.Label2.Text = "Filename to generate, or target folder to generate to:"
        '
        'MhtFileTextBox
        '
        Me.MhtFileTextBox.Location = New System.Drawing.Point(0, 24)
        Me.MhtFileTextBox.Multiline = True
        Me.MhtFileTextBox.Name = "MhtFileTextBox"
        Me.MhtFileTextBox.Size = New System.Drawing.Size(416, 32)
        Me.MhtFileTextBox.TabIndex = 30
        Me.MhtFileTextBox.Text = ""
        '
        'BuildMhtButton
        '
        Me.BuildMhtButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.BuildMhtButton.Location = New System.Drawing.Point(288, 88)
        Me.BuildMhtButton.Name = "BuildMhtButton"
        Me.BuildMhtButton.Size = New System.Drawing.Size(60, 23)
        Me.BuildMhtButton.TabIndex = 29
        Me.BuildMhtButton.Text = "Save"
        '
        'MemoryRadioButton
        '
        Me.MemoryRadioButton.Location = New System.Drawing.Point(88, 60)
        Me.MemoryRadioButton.Name = "MemoryRadioButton"
        Me.MemoryRadioButton.Size = New System.Drawing.Size(64, 24)
        Me.MemoryRadioButton.TabIndex = 33
        Me.MemoryRadioButton.Text = "Memory"
        '
        'DiskTempRadioButton
        '
        Me.DiskTempRadioButton.Location = New System.Drawing.Point(152, 60)
        Me.DiskTempRadioButton.Name = "DiskTempRadioButton"
        Me.DiskTempRadioButton.Size = New System.Drawing.Size(112, 24)
        Me.DiskTempRadioButton.TabIndex = 34
        Me.DiskTempRadioButton.Text = "Disk, Temporary"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(4, 64)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(80, 16)
        Me.Label6.TabIndex = 36
        Me.Label6.Text = "Temp Storage:"
        '
        'DiskPermRadioButton
        '
        Me.DiskPermRadioButton.Location = New System.Drawing.Point(264, 60)
        Me.DiskPermRadioButton.Name = "DiskPermRadioButton"
        Me.DiskPermRadioButton.Size = New System.Drawing.Size(112, 24)
        Me.DiskPermRadioButton.TabIndex = 35
        Me.DiskPermRadioButton.Text = "Disk, Permanent"
        '
        'TabPage6
        '
        Me.TabPage6.Controls.Add(Me.BuildMhtMemoryButton)
        Me.TabPage6.Location = New System.Drawing.Point(4, 25)
        Me.TabPage6.Name = "TabPage6"
        Me.TabPage6.Size = New System.Drawing.Size(424, 121)
        Me.TabPage6.TabIndex = 1
        Me.TabPage6.Text = "In Memory"
        '
        'BuildMhtMemoryButton
        '
        Me.BuildMhtMemoryButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.BuildMhtMemoryButton.Location = New System.Drawing.Point(280, 88)
        Me.BuildMhtMemoryButton.Name = "BuildMhtMemoryButton"
        Me.BuildMhtMemoryButton.Size = New System.Drawing.Size(132, 23)
        Me.BuildMhtMemoryButton.TabIndex = 30
        Me.BuildMhtMemoryButton.Text = "Display"
        '
        'TabPage3
        '
        Me.TabPage3.Controls.Add(Me.ViewHtmlButton)
        Me.TabPage3.Controls.Add(Me.Label4)
        Me.TabPage3.Controls.Add(Me.HtmlFileTextBox)
        Me.TabPage3.Controls.Add(Me.SaveHtmlButton)
        Me.TabPage3.Location = New System.Drawing.Point(4, 22)
        Me.TabPage3.Name = "TabPage3"
        Me.TabPage3.Size = New System.Drawing.Size(432, 150)
        Me.TabPage3.TabIndex = 2
        Me.TabPage3.Text = "Web Page (html only)"
        '
        'ViewHtmlButton
        '
        Me.ViewHtmlButton.Enabled = False
        Me.ViewHtmlButton.Location = New System.Drawing.Point(360, 112)
        Me.ViewHtmlButton.Name = "ViewHtmlButton"
        Me.ViewHtmlButton.Size = New System.Drawing.Size(60, 23)
        Me.ViewHtmlButton.TabIndex = 24
        Me.ViewHtmlButton.Text = "View"
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(8, 8)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(266, 16)
        Me.Label4.TabIndex = 23
        Me.Label4.Text = "Filename to generate, or target folder to generate to:"
        '
        'HtmlFileTextBox
        '
        Me.HtmlFileTextBox.Location = New System.Drawing.Point(8, 24)
        Me.HtmlFileTextBox.Multiline = True
        Me.HtmlFileTextBox.Name = "HtmlFileTextBox"
        Me.HtmlFileTextBox.Size = New System.Drawing.Size(416, 80)
        Me.HtmlFileTextBox.TabIndex = 22
        Me.HtmlFileTextBox.Text = ""
        '
        'SaveHtmlButton
        '
        Me.SaveHtmlButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SaveHtmlButton.Location = New System.Drawing.Point(296, 112)
        Me.SaveHtmlButton.Name = "SaveHtmlButton"
        Me.SaveHtmlButton.Size = New System.Drawing.Size(60, 23)
        Me.SaveHtmlButton.TabIndex = 21
        Me.SaveHtmlButton.Text = "Save"
        '
        'TabPage2
        '
        Me.TabPage2.Controls.Add(Me.ViewCompleteButton)
        Me.TabPage2.Controls.Add(Me.BuildFileButton)
        Me.TabPage2.Controls.Add(Me.Label3)
        Me.TabPage2.Controls.Add(Me.CompleteFileTextBox)
        Me.TabPage2.Location = New System.Drawing.Point(4, 22)
        Me.TabPage2.Name = "TabPage2"
        Me.TabPage2.Size = New System.Drawing.Size(432, 150)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Text = "Web Page (complete)"
        '
        'ViewCompleteButton
        '
        Me.ViewCompleteButton.Enabled = False
        Me.ViewCompleteButton.Location = New System.Drawing.Point(360, 112)
        Me.ViewCompleteButton.Name = "ViewCompleteButton"
        Me.ViewCompleteButton.Size = New System.Drawing.Size(60, 23)
        Me.ViewCompleteButton.TabIndex = 22
        Me.ViewCompleteButton.Text = "View"
        '
        'BuildFileButton
        '
        Me.BuildFileButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.BuildFileButton.Location = New System.Drawing.Point(296, 112)
        Me.BuildFileButton.Name = "BuildFileButton"
        Me.BuildFileButton.Size = New System.Drawing.Size(60, 23)
        Me.BuildFileButton.TabIndex = 21
        Me.BuildFileButton.Text = "Save"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(8, 8)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(266, 16)
        Me.Label3.TabIndex = 20
        Me.Label3.Text = "Filename to generate, or target folder to generate to:"
        '
        'CompleteFileTextBox
        '
        Me.CompleteFileTextBox.Location = New System.Drawing.Point(8, 24)
        Me.CompleteFileTextBox.Multiline = True
        Me.CompleteFileTextBox.Name = "CompleteFileTextBox"
        Me.CompleteFileTextBox.Size = New System.Drawing.Size(416, 80)
        Me.CompleteFileTextBox.TabIndex = 19
        Me.CompleteFileTextBox.Text = ""
        '
        'TabPage4
        '
        Me.TabPage4.Controls.Add(Me.ViewTextButton)
        Me.TabPage4.Controls.Add(Me.Label5)
        Me.TabPage4.Controls.Add(Me.TextFileTextBox)
        Me.TabPage4.Controls.Add(Me.SaveTextButton)
        Me.TabPage4.Location = New System.Drawing.Point(4, 22)
        Me.TabPage4.Name = "TabPage4"
        Me.TabPage4.Size = New System.Drawing.Size(432, 150)
        Me.TabPage4.TabIndex = 3
        Me.TabPage4.Text = "Text"
        '
        'ViewTextButton
        '
        Me.ViewTextButton.Enabled = False
        Me.ViewTextButton.Location = New System.Drawing.Point(360, 112)
        Me.ViewTextButton.Name = "ViewTextButton"
        Me.ViewTextButton.Size = New System.Drawing.Size(60, 23)
        Me.ViewTextButton.TabIndex = 24
        Me.ViewTextButton.Text = "View"
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(8, 8)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(266, 16)
        Me.Label5.TabIndex = 23
        Me.Label5.Text = "Filename to generate, or target folder to generate to:"
        '
        'TextFileTextBox
        '
        Me.TextFileTextBox.Location = New System.Drawing.Point(8, 24)
        Me.TextFileTextBox.Multiline = True
        Me.TextFileTextBox.Name = "TextFileTextBox"
        Me.TextFileTextBox.Size = New System.Drawing.Size(416, 80)
        Me.TextFileTextBox.TabIndex = 22
        Me.TextFileTextBox.Text = ""
        '
        'SaveTextButton
        '
        Me.SaveTextButton.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.SaveTextButton.Location = New System.Drawing.Point(296, 112)
        Me.SaveTextButton.Name = "SaveTextButton"
        Me.SaveTextButton.Size = New System.Drawing.Size(60, 23)
        Me.SaveTextButton.TabIndex = 21
        Me.SaveTextButton.Text = "Save"
        '
        'IFrameCheckBox
        '
        Me.IFrameCheckBox.Location = New System.Drawing.Point(172, 272)
        Me.IFrameCheckBox.Name = "IFrameCheckBox"
        Me.IFrameCheckBox.Size = New System.Drawing.Size(152, 24)
        Me.IFrameCheckBox.TabIndex = 23
        Me.IFrameCheckBox.Text = "Remove <IFRAME> tags"
        '
        'ScriptCheckBox
        '
        Me.ScriptCheckBox.Location = New System.Drawing.Point(12, 272)
        Me.ScriptCheckBox.Name = "ScriptCheckBox"
        Me.ScriptCheckBox.Size = New System.Drawing.Size(148, 24)
        Me.ScriptCheckBox.TabIndex = 22
        Me.ScriptCheckBox.Text = "Remove <SCRIPT> tags"
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(12, 336)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(80, 16)
        Me.Label7.TabIndex = 29
        Me.Label7.Text = "Text Encoding:"
        '
        'TextEncodingComboBox
        '
        Me.TextEncodingComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.TextEncodingComboBox.Items.AddRange(New Object() {"Autodetect", "Unicode", "Windows-1252", "UTF-8"})
        Me.TextEncodingComboBox.Location = New System.Drawing.Point(100, 332)
        Me.TextEncodingComboBox.Name = "TextEncodingComboBox"
        Me.TextEncodingComboBox.Size = New System.Drawing.Size(136, 21)
        Me.TextEncodingComboBox.TabIndex = 30
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Label13)
        Me.GroupBox1.Controls.Add(Me.Label12)
        Me.GroupBox1.Controls.Add(Me.Label10)
        Me.GroupBox1.Controls.Add(Me.Label11)
        Me.GroupBox1.Controls.Add(Me.AuthPasswordTextBox)
        Me.GroupBox1.Controls.Add(Me.AuthUserTextBox)
        Me.GroupBox1.Controls.Add(Me.Label9)
        Me.GroupBox1.Controls.Add(Me.Label8)
        Me.GroupBox1.Controls.Add(Me.ProxyPasswordTextBox)
        Me.GroupBox1.Controls.Add(Me.ProxyUserTextBox)
        Me.GroupBox1.Controls.Add(Me.Label1)
        Me.GroupBox1.Controls.Add(Me.ProxyUrlTextBox)
        Me.GroupBox1.Controls.Add(Me.ProxyAuthCheckBox)
        Me.GroupBox1.Controls.Add(Me.AuthCheckBox)
        Me.GroupBox1.Controls.Add(Me.ViewUrlButton)
        Me.GroupBox1.Controls.Add(Me.UrlTextBox)
        Me.GroupBox1.Location = New System.Drawing.Point(4, 4)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(452, 244)
        Me.GroupBox1.TabIndex = 33
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Target URL"
        '
        'Label13
        '
        Me.Label13.Location = New System.Drawing.Point(224, 192)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(128, 32)
        Me.Label13.TabIndex = 48
        Me.Label13.Text = "(leave blank to use current user credentials)"
        '
        'Label12
        '
        Me.Label12.Location = New System.Drawing.Point(224, 84)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(128, 32)
        Me.Label12.TabIndex = 47
        Me.Label12.Text = "(leave blank to use current user credentials)"
        '
        'Label10
        '
        Me.Label10.Location = New System.Drawing.Point(36, 104)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(64, 16)
        Me.Label10.TabIndex = 46
        Me.Label10.Text = "password:"
        '
        'Label11
        '
        Me.Label11.Location = New System.Drawing.Point(36, 80)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(64, 16)
        Me.Label11.TabIndex = 45
        Me.Label11.Text = "user:"
        '
        'AuthPasswordTextBox
        '
        Me.AuthPasswordTextBox.Location = New System.Drawing.Point(108, 104)
        Me.AuthPasswordTextBox.Name = "AuthPasswordTextBox"
        Me.AuthPasswordTextBox.TabIndex = 44
        Me.AuthPasswordTextBox.Text = ""
        '
        'AuthUserTextBox
        '
        Me.AuthUserTextBox.Location = New System.Drawing.Point(108, 80)
        Me.AuthUserTextBox.Name = "AuthUserTextBox"
        Me.AuthUserTextBox.TabIndex = 43
        Me.AuthUserTextBox.Text = ""
        '
        'Label9
        '
        Me.Label9.Location = New System.Drawing.Point(36, 212)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(64, 16)
        Me.Label9.TabIndex = 42
        Me.Label9.Text = "password:"
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(36, 188)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(64, 16)
        Me.Label8.TabIndex = 41
        Me.Label8.Text = "user:"
        '
        'ProxyPasswordTextBox
        '
        Me.ProxyPasswordTextBox.Location = New System.Drawing.Point(108, 212)
        Me.ProxyPasswordTextBox.Name = "ProxyPasswordTextBox"
        Me.ProxyPasswordTextBox.TabIndex = 40
        Me.ProxyPasswordTextBox.Text = ""
        '
        'ProxyUserTextBox
        '
        Me.ProxyUserTextBox.Location = New System.Drawing.Point(108, 188)
        Me.ProxyUserTextBox.Name = "ProxyUserTextBox"
        Me.ProxyUserTextBox.TabIndex = 39
        Me.ProxyUserTextBox.Text = ""
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(36, 164)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(64, 16)
        Me.Label1.TabIndex = 38
        Me.Label1.Text = "proxy URL:"
        '
        'ProxyUrlTextBox
        '
        Me.ProxyUrlTextBox.Location = New System.Drawing.Point(108, 164)
        Me.ProxyUrlTextBox.Name = "ProxyUrlTextBox"
        Me.ProxyUrlTextBox.Size = New System.Drawing.Size(332, 20)
        Me.ProxyUrlTextBox.TabIndex = 37
        Me.ProxyUrlTextBox.Text = ""
        '
        'ProxyAuthCheckBox
        '
        Me.ProxyAuthCheckBox.Location = New System.Drawing.Point(16, 136)
        Me.ProxyAuthCheckBox.Name = "ProxyAuthCheckBox"
        Me.ProxyAuthCheckBox.Size = New System.Drawing.Size(268, 24)
        Me.ProxyAuthCheckBox.TabIndex = 36
        Me.ProxyAuthCheckBox.Text = "To get to this URL, we must go through a proxy:"
        '
        'AuthCheckBox
        '
        Me.AuthCheckBox.Location = New System.Drawing.Point(16, 52)
        Me.AuthCheckBox.Name = "AuthCheckBox"
        Me.AuthCheckBox.Size = New System.Drawing.Size(188, 24)
        Me.AuthCheckBox.TabIndex = 35
        Me.AuthCheckBox.Text = "This URL requires authentication"
        '
        'ViewUrlButton
        '
        Me.ViewUrlButton.Location = New System.Drawing.Point(384, 52)
        Me.ViewUrlButton.Name = "ViewUrlButton"
        Me.ViewUrlButton.Size = New System.Drawing.Size(60, 23)
        Me.ViewUrlButton.TabIndex = 34
        Me.ViewUrlButton.Text = "View"
        '
        'UrlTextBox
        '
        Me.UrlTextBox.Location = New System.Drawing.Point(8, 24)
        Me.UrlTextBox.Name = "UrlTextBox"
        Me.UrlTextBox.Size = New System.Drawing.Size(436, 20)
        Me.UrlTextBox.TabIndex = 33
        Me.UrlTextBox.Text = "http://www.codinghorror.com/blog/"
        '
        'RecursionCheckBox
        '
        Me.RecursionCheckBox.Checked = True
        Me.RecursionCheckBox.CheckState = System.Windows.Forms.CheckState.Checked
        Me.RecursionCheckBox.Location = New System.Drawing.Point(12, 252)
        Me.RecursionCheckBox.Name = "RecursionCheckBox"
        Me.RecursionCheckBox.Size = New System.Drawing.Size(324, 20)
        Me.RecursionCheckBox.TabIndex = 34
        Me.RecursionCheckBox.Text = "Allow recursive file retrieval (eg, <FRAME> and <IFRAME>)"
        '
        'BrowserIdTextBox
        '
        Me.BrowserIdTextBox.Location = New System.Drawing.Point(100, 308)
        Me.BrowserIdTextBox.Name = "BrowserIdTextBox"
        Me.BrowserIdTextBox.Size = New System.Drawing.Size(352, 20)
        Me.BrowserIdTextBox.TabIndex = 35
        Me.BrowserIdTextBox.Text = ""
        '
        'Label14
        '
        Me.Label14.Location = New System.Drawing.Point(12, 312)
        Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(64, 16)
        Me.Label14.TabIndex = 43
        Me.Label14.Text = "Browser ID:"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(460, 553)
        Me.Controls.Add(Me.Label14)
        Me.Controls.Add(Me.BrowserIdTextBox)
        Me.Controls.Add(Me.RecursionCheckBox)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.TextEncodingComboBox)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.IFrameCheckBox)
        Me.Controls.Add(Me.ScriptCheckBox)
        Me.Controls.Add(Me.TabControl1)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "MhtBuilder Demo Form"
        Me.TabControl1.ResumeLayout(False)
        Me.TabPage1.ResumeLayout(False)
        Me.TabControl2.ResumeLayout(False)
        Me.TabPage5.ResumeLayout(False)
        Me.TabPage6.ResumeLayout(False)
        Me.TabPage3.ResumeLayout(False)
        Me.TabPage2.ResumeLayout(False)
        Me.TabPage4.ResumeLayout(False)
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private _mht As New Mht.Builder    

    Private Sub BuildMhtButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BuildMhtButton.Click
        Cursor.Current = Cursors.WaitCursor

        Dim st As Mht.Builder.FileStorage
        If MemoryRadioButton.Checked Then
            st = Mht.Builder.FileStorage.Memory
        End If
        If DiskTempRadioButton.Checked Then
            st = Mht.Builder.FileStorage.DiskTemporary
        End If
        If DiskPermRadioButton.Checked Then
            st = Mht.Builder.FileStorage.DiskPermanent
        End If        

        MhtFileTextBox.Text = _mht.SavePageArchive(MhtFileTextBox.Text, st, UrlTextBox.Text)
        Cursor.Current = Cursors.Default
        ViewMhtButton.Enabled = True
    End Sub

    Private Sub BuildMhtMemoryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BuildMhtMemoryButton.Click
        Cursor.Current = Cursors.WaitCursor
        Dim f As New Form2
        f.Data = _mht.GetPageArchive(UrlTextBox.Text)
        f.ShowDialog(Me)
        Cursor.Current = Cursors.Default
    End Sub

    Private Sub BuildFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BuildFileButton.Click
        Cursor.Current = Cursors.WaitCursor
        CompleteFileTextBox.Text = _mht.SavePageComplete(CompleteFileTextBox.Text, UrlTextBox.Text)
        Cursor.Current = Cursors.Default
        ViewCompleteButton.Enabled = True
    End Sub

    Private Sub SaveHtmlButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveHtmlButton.Click
        Cursor.Current = Cursors.WaitCursor
        HtmlFileTextBox.Text = _mht.SavePage(HtmlFileTextBox.Text, UrlTextBox.Text)
        Cursor.Current = Cursors.Default
        ViewHtmlButton.Enabled = True
    End Sub

    Private Sub SaveTextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveTextButton.Click
        _mht.Url = UrlTextBox.Text

        Cursor.Current = Cursors.WaitCursor
        TextFileTextBox.Text = _mht.SavePageText(TextFileTextBox.Text)
        Cursor.Current = Cursors.Default
        ViewTextButton.Enabled = True
    End Sub

    '--
    '-- removes all unsafe characters to form a valid filename
    '--
    Private Function MakeSafeFilename(ByVal strAny As String) As String
        strAny = Regex.Replace(strAny, "^http://|/$", "", RegexOptions.IgnoreCase)
        Return Regex.Replace(strAny, "[\/\\\:\*\?\""\<\>\|]", "_")
    End Function

    '--
    '-- auto-generate filenames for each textbox based on the URL
    '--
    Private Sub AutoGenerateFilename()
        Dim strSafeName As String
        strSafeName = AppDomain.CurrentDomain.BaseDirectory
        MhtFileTextBox.Text = strSafeName
        HtmlFileTextBox.Text = strSafeName
        CompleteFileTextBox.Text = strSafeName
        TextFileTextBox.Text = strSafeName
    End Sub

    Private Sub UrlTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        AutoGenerateFilename()
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AutoGenerateFilename()
    End Sub

    Private Sub ViewUrlButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        System.Diagnostics.Process.Start(UrlTextBox.Text)
    End Sub

    Private Sub ViewFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewMhtButton.Click
        System.Diagnostics.Process.Start(MhtFileTextBox.Text)
    End Sub

    Private Sub ViewHtmlButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewHtmlButton.Click
        System.Diagnostics.Process.Start(HtmlFileTextBox.Text)
    End Sub

    Private Sub ViewCompleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewCompleteButton.Click
        System.Diagnostics.Process.Start(CompleteFileTextBox.Text)
    End Sub

    Private Sub ViewTextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewTextButton.Click
        System.Diagnostics.Process.Start(TextFileTextBox.Text)
    End Sub

    Private Sub ScriptCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ScriptCheckBox.CheckedChanged
        _mht.StripScripts = ScriptCheckBox.Checked
    End Sub

    Private Sub IFrameCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IFrameCheckBox.CheckedChanged
        _mht.StripIframes = IFrameCheckBox.Checked
    End Sub

    Private Sub TextEncodingComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextEncodingComboBox.SelectedIndexChanged
        Select Case TextEncodingComboBox.SelectedItem.ToString
            Case "Autodetect"
                _mht.TextEncoding = Nothing
            Case "Unicode"
                _mht.TextEncoding = System.Text.Encoding.Unicode
            Case Else
                _mht.TextEncoding = System.Text.Encoding.UTF8
        End Select
    End Sub

    Private Sub AuthCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AuthCheckBox.CheckedChanged
        _mht.AuthenticationRequired = AuthCheckBox.Checked
    End Sub

    Private Sub ProxyAuthCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProxyAuthCheckBox.CheckedChanged
        _mht.ProxyAuthenticationRequired = ProxyAuthCheckBox.Checked
    End Sub

    Private Sub ProxyUrlTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProxyUrlTextBox.TextChanged
        ProxyAuthCheckBox.Checked = (ProxyUrlTextBox.Text <> "")
        _mht.ProxyUrl = ProxyUrlTextBox.Text
    End Sub

    Private Sub ProxyUserTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProxyUserTextBox.TextChanged
        _mht.ProxyUser = ProxyUserTextBox.Text
    End Sub

    Private Sub ProxyPasswordTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProxyPasswordTextBox.TextChanged
        _mht.ProxyPassword = ProxyPasswordTextBox.Text
    End Sub

    Private Sub AuthPasswordTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AuthPasswordTextBox.TextChanged
        _mht.AuthenticationPassword = AuthPasswordTextBox.Text
    End Sub

    Private Sub AuthUserTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AuthUserTextBox.TextChanged
        _mht.AuthenticationUser = AuthUserTextBox.Text
    End Sub

    Private Sub RecursionCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RecursionCheckBox.CheckedChanged
        _mht.AllowRecursiveFileRetrieval = RecursionCheckBox.Checked
    End Sub

    Private Sub BrowserIdTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrowserIdTextBox.TextChanged
        _mht.BrowserIdString = BrowserIdTextBox.Text
    End Sub
End Class

bytes=37728