/Source Code/PowerSong/Plug Ins/frmCreatePlugIn.vb
Visual Basic | 63 lines | 45 code | 15 blank | 3 comment | 1 complexity | ee45145dd9bd004f8210c2fa5e987f7f MD5 | raw file
- Imports System.Windows.Forms
- Imports System.IO
- Imports PowerSong.SongDatabase
-
- Public Class frmCreatePlugIn
-
- Private FDatabase As Database = Nothing
-
- Public Sub New(ByVal database As Database)
- InitializeComponent()
- FDatabase = database
- End Sub
-
- Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
-
- Try
-
- ' Perform some checks
- If txtName.Text.Trim = "" Then Throw New ApplicationException("Please specify the name of the plugin.")
- If txtLocation.Text.Trim = "" Then Throw New ApplicationException("Please specify the location of the plugin.")
- If txtFolderName.Text.Trim = "" Then Throw New ApplicationException("Please specify the name of the folder for the new plugin.")
-
- ' Create the folder where the plugin should reside
- Dim TargetDirectory As String = txtLocation.Text + "\" + txtFolderName.Text
- If Directory.Exists(TargetDirectory) Then Throw New ApplicationException("That folder already exists at the specified location.")
- Directory.CreateDirectory(TargetDirectory)
-
- ' Create basic code files
- FDatabase.CreateNewPlugin(TargetDirectory, Database.InitialContentFolder + "\New.plugin")
-
- ' Show feedback
- MsgBox("The plugin has been created at " + txtLocation.Text + "\" + txtFolderName.Text + ".", MsgBoxStyle.Information)
-
- ' Close the form
- Me.DialogResult = System.Windows.Forms.DialogResult.OK
- Me.Close()
-
- Catch ex As Exception
- MsgBox(ex.Message, MsgBoxStyle.Exclamation)
- End Try
-
- End Sub
-
- Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
- Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
- Me.Close()
- End Sub
-
- Private Sub btnSelectFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectFolder.Click
- If dlgSelectPluginFolder.ShowDialog = Windows.Forms.DialogResult.OK Then
- txtLocation.Text = dlgSelectPluginFolder.SelectedPath
- End If
- End Sub
-
- Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged
- txtFolderName.Text = txtName.Text
- End Sub
-
- Private Sub frmCreatePlugIn_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- txtLocation.Text = FileIO.SpecialDirectories.Desktop
- End Sub
-
- End Class