Click here to Skip to main content
15,894,630 members
Articles / Programming Languages / Visual Basic

liteWait PowerPoint to HTML Converter

Rate me:
Please Sign up or sign in to vote.
3.50/5 (6 votes)
25 Oct 20021 min read 145.9K   1.5K   33  
Scans a target directory for Microsoft PowerPoint presentations and automatically convert them to HTML to reduce network traffic and to allow for presentation previewing without downloading the entire PowerPoint file.
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.IO

Public Class SettingsForm
    Inherits System.Windows.Forms.Form

    Public Sub New()
        MyBase.New
        SettingsForm = Me
        'This call is required by the Win Form Designer.
        InitializeComponent()
        InitializeSettings()
    End Sub

    'gets the settings from the xml file
    Public Function InitializeSettings()
        Dim dsSettings As New DataSet("settings")
        dsSettings.ReadXml("settings.xml")
        ScanDir.Text = dsSettings.Tables("settings").Rows(0).Item("scanDirectory")
        ScanInterval.Text = dsSettings.Tables("settings").Rows(0).Item("scanInterval")
        HTMLdir.Text = dsSettings.Tables("settings").Rows(0).Item("htmlDirectory")
        LastRun.Text = dsSettings.Tables("settings").Rows(0).Item("lastRun")
    End Function

    '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

    'Save settings if the form entries are valid
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If validateSettings() Then
            If saveSettings() = False Then
                MsgBox("There was a problem saving settings, check the error log for more info")
            End If
        End If
    End Sub

    'validate the form and return true if everything is okay
    Public Function validateSettings() As Boolean
        Try
            Dim testInt As Integer = CInt(ScanInterval.Text)
            If testInt < 1 Then
                MsgBox("Scan Interval needs to be more than 0")
            End If
        Catch
            MsgBox("Scan Interval must be a number")
            Return False
        End Try
        If Not Directory.Exists(ScanDir.Text) Then
            MsgBox("not a valid Scan Directory")
            Return False
        End If
        Return True
    End Function

    'save the form values to the xml file
    Public Function saveSettings() As Boolean
        Dim dsSettings As New DataSet("settings")
        dsSettings.ReadXml("settings.xml")
        dsSettings.Tables("settings").Rows(0).Item("scanDirectory") = ScanDir.Text
        dsSettings.Tables("settings").Rows(0).Item("scanInterval") = ScanInterval.Text
        dsSettings.Tables("settings").Rows(0).Item("htmlDirectory") = HTMLdir.Text
        dsSettings.Tables("settings").Rows(0).Item("lastRun") = LastRun.Text
        dsSettings.WriteXml("settings.xml")
        Return True
    End Function

#Region " Windows Form Designer generated code "

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

    Dim WithEvents SettingsForm As System.Windows.Forms.Form

    '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 lblScanDir As System.Windows.Forms.Label
    Friend WithEvents lblScanInterval As System.Windows.Forms.Label
    Friend WithEvents ScanInterval As System.Windows.Forms.TextBox
    Friend WithEvents lblHTMLdir As System.Windows.Forms.Label
    Friend WithEvents HTMLdir As System.Windows.Forms.TextBox
    Friend WithEvents lblMinutes As System.Windows.Forms.Label
    Friend WithEvents ScanDir As System.Windows.Forms.TextBox
    Friend WithEvents lblLastRun As System.Windows.Forms.Label
    Friend WithEvents LastRun As System.Windows.Forms.Label
    Friend WithEvents btnSave As System.Windows.Forms.Button
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Private Sub InitializeComponent()
        Me.ScanDir = New System.Windows.Forms.TextBox()
        Me.lblScanDir = New System.Windows.Forms.Label()
        Me.lblScanInterval = New System.Windows.Forms.Label()
        Me.ScanInterval = New System.Windows.Forms.TextBox()
        Me.lblHTMLdir = New System.Windows.Forms.Label()
        Me.HTMLdir = New System.Windows.Forms.TextBox()
        Me.lblMinutes = New System.Windows.Forms.Label()
        Me.lblLastRun = New System.Windows.Forms.Label()
        Me.LastRun = New System.Windows.Forms.Label()
        Me.btnSave = New System.Windows.Forms.Button()
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog()
        Me.SuspendLayout()
        '
        'ScanDir
        '
        Me.ScanDir.Location = New System.Drawing.Point(120, 16)
        Me.ScanDir.Name = "ScanDir"
        Me.ScanDir.Size = New System.Drawing.Size(184, 20)
        Me.ScanDir.TabIndex = 2
        Me.ScanDir.Text = ""
        '
        'lblScanDir
        '
        Me.lblScanDir.Location = New System.Drawing.Point(8, 16)
        Me.lblScanDir.Name = "lblScanDir"
        Me.lblScanDir.TabIndex = 3
        Me.lblScanDir.Text = "Scan Directory:"
        '
        'lblScanInterval
        '
        Me.lblScanInterval.Location = New System.Drawing.Point(8, 48)
        Me.lblScanInterval.Name = "lblScanInterval"
        Me.lblScanInterval.TabIndex = 5
        Me.lblScanInterval.Text = "Scan Interval:"
        '
        'ScanInterval
        '
        Me.ScanInterval.Location = New System.Drawing.Point(120, 48)
        Me.ScanInterval.Name = "ScanInterval"
        Me.ScanInterval.Size = New System.Drawing.Size(40, 20)
        Me.ScanInterval.TabIndex = 4
        Me.ScanInterval.Text = ""
        '
        'lblHTMLdir
        '
        Me.lblHTMLdir.Location = New System.Drawing.Point(8, 75)
        Me.lblHTMLdir.Name = "lblHTMLdir"
        Me.lblHTMLdir.TabIndex = 7
        Me.lblHTMLdir.Text = "HTML Directory:"
        '
        'HTMLdir
        '
        Me.HTMLdir.Location = New System.Drawing.Point(120, 75)
        Me.HTMLdir.Name = "HTMLdir"
        Me.HTMLdir.Size = New System.Drawing.Size(184, 20)
        Me.HTMLdir.TabIndex = 6
        Me.HTMLdir.Text = ""
        '
        'lblMinutes
        '
        Me.lblMinutes.Location = New System.Drawing.Point(168, 48)
        Me.lblMinutes.Name = "lblMinutes"
        Me.lblMinutes.TabIndex = 8
        Me.lblMinutes.Text = "minutes"
        '
        'lblLastRun
        '
        Me.lblLastRun.Location = New System.Drawing.Point(8, 104)
        Me.lblLastRun.Name = "lblLastRun"
        Me.lblLastRun.TabIndex = 9
        Me.lblLastRun.Text = "last successful run:"
        '
        'LastRun
        '
        Me.LastRun.Location = New System.Drawing.Point(120, 104)
        Me.LastRun.Name = "LastRun"
        Me.LastRun.Size = New System.Drawing.Size(184, 23)
        Me.LastRun.TabIndex = 10
        '
        'btnSave
        '
        Me.btnSave.Location = New System.Drawing.Point(184, 136)
        Me.btnSave.Name = "btnSave"
        Me.btnSave.TabIndex = 11
        Me.btnSave.Text = "Save"
        '
        'SettingsForm
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(328, 173)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnSave, Me.LastRun, Me.lblLastRun, Me.lblMinutes, Me.lblHTMLdir, Me.HTMLdir, Me.lblScanInterval, Me.ScanInterval, Me.lblScanDir, Me.ScanDir})
        Me.Name = "SettingsForm"
        Me.Text = "liteWait Settings"
        Me.ResumeLayout(False)

    End Sub

#End Region
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Technical Lead Independent Consultant
United States United States
___________________________
J A M E S C O L E M A N
Director, Technical Services
Linked-In: http://www.linkedin.com/in/jameswcoleman
Blog: ledtalks.wordpress.com

Comments and Discussions