Click here to Skip to main content
15,867,765 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting "'Namespace' statements can occur only at file or namespace level" error. How to fix it?
C#
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Drawing
Imports System.IO
Imports System.Linq
Imports System.Windows.Forms
Imports System.Xml



Public Class Form1

    Private Su



    Public Class MainForm


Namespace NVCompressGUI

            Inherits Form
            Private sourcePath As String = "no"

            Private targetPath As String = "no"

            Private preparedTargetPath As String = "empty"

            Private fileCount As Integer = 0

            Private i As Integer = 0

            Private prozent As Double = 0.0

            Private arguments As String = "-nomips "

            Private extensions As String() = New String() {"png", "jpg", "tga", "jpeg"}

            Private xmlDocument As New XmlDocument()

            Private documentPath As String = Application.StartupPath + "\bin\settings.xml"

            Private image As System.Drawing.Image = Nothing

            Private components As IContainer = Nothing

            Private textBox8 As TextBox

            Private checkBox2 As CheckBox

            Private textBox3 As TextBox

            Private pictureBox1 As PictureBox

            Private label4 As Label

            Private checkBox1 As CheckBox

            Private panel1 As Panel

            Private textBox6 As TextBox

            Private label3 As Label

            Private textBox5 As TextBox

            Private textBox4 As TextBox

            Private button3 As Button

            Private radioButton2 As RadioButton

            Private radioButton1 As RadioButton

            Private label2 As Label

            Private comboBox1 As ComboBox

            Private label1 As Label

            Private checkedListBox1 As CheckedListBox

            Private textBox2 As TextBox

            Private button2 As Button

            Private textBox1 As TextBox

            Private button1 As Button

            Public Sub New()
                Me.InitializeComponent()
            End Sub

            Private Sub MainFormLoad(sender As Object, e As EventArgs)
                Me.comboBox1.SelectedItem = "DXT1"
                Me.radioButton1.Checked = True
                Me.textBox6.Text = "0 %"
                Try
                    Me.xmlDocument.Load(Me.documentPath)
                Catch
                    Me.xmlDocument.LoadXml("<settings>")
                    MessageBox.Show("Settings missing ! ")
                    MyBase.Close()
                End Try
                Me.sourcePath = Me.GetSetting("SourceFolder", Me.sourcePath)
                If Not Directory.Exists(Me.sourcePath) Then
                    Me.sourcePath = "empty"
                    Me.textBox1.Text = Me.sourcePath
                    Me.textBox2.Text = "empty"
                Else
                    Me.textBox1.Text = Me.sourcePath
				Me.fileCount = (From f In Directory.GetFiles(Me.sourcePath, "*.*") Where Me.extensions.Contains(f.Split(New Char() {"."C}).Last(Of String)().ToLower())f).ToArray(Of String)().Length
                    If Me.fileCount <> 0 Then
					Me.loadImagePreview((From f In Directory.GetFiles(Me.sourcePath, "*.*") Where Me.extensions.Contains(f.Split(New Char() {"."C}).Last(Of String)().ToLower())f).ToArray(Of String)().FirstOrDefault(Of String)())
                    End If
                    Me.textBox5.Text = Convert.ToString(Me.fileCount)
                    Me.prozent = 100.0 / CDbl(Me.fileCount)
                End If
                Me.targetPath = Me.GetSetting("TargetFolder", Me.targetPath)
                If Not Directory.Exists(Me.targetPath) Then
                    Me.targetPath = "empty"
                    Me.textBox2.Text = Me.targetPath
                Else
                    Me.textBox2.Text = Me.targetPath
                End If
                Me.comboBox1.SelectedItem = Me.GetSetting("Format", "Format")
                For i As Integer = 0 To 6
                    If Me.GetSetting("Option" + Convert.ToString(i), "Option" + Convert.ToString(i)) = "Checked" Then
                        Me.checkedListBox1.SetItemChecked(i, True)
                    End If
                Next
                If Me.GetSetting("Address", "Address") = "Clamp" Then
                    Me.radioButton2.Checked = False
                Else
                    Me.radioButton2.Checked = True
                End If

            End Sub

            Private Sub MainformClosing(sender As Object, e As FormClosingEventArgs)
                Me.PutSetting("SourceFolder", Me.sourcePath)
                Me.PutSetting("TargetFolder", Me.targetPath)
                Me.PutSetting("Format", Me.comboBox1.Text)
                For i As Integer = 0 To 6
                    Me.PutSetting("Option" + Convert.ToString(i), Me.checkedListBox1.GetItemCheckState(i).ToString())
                Next
                If Me.radioButton2.Checked Then
                    Me.PutSetting("Address", "Repeat")
                Else
                    Me.PutSetting("Address", "Clamp")
                End If

            End Sub

            Private Sub Button1Click(sender As Object, e As EventArgs)
                Dim folderBrowserDialog As New FolderBrowserDialog()
                If Directory.Exists(Me.sourcePath) Then
                    folderBrowserDialog.SelectedPath = Me.sourcePath
                End If
                Dim dialogResult__1 As DialogResult = folderBrowserDialog.ShowDialog(Me)
                If dialogResult__1 = DialogResult.OK Then
                    Me.textBox1.Text = folderBrowserDialog.SelectedPath
                    Me.sourcePath = folderBrowserDialog.SelectedPath
				Me.fileCount = (From f In Directory.GetFiles(Me.sourcePath, "*.*") Where Me.extensions.Contains(f.Split(New Char() {"."C}).Last(Of String)().ToLower())f).ToArray(Of String)().Length
                    If Me.fileCount = 0 Then
                        MessageBox.Show("no images found")
                    Else
                        Me.prozent = 100.0 / CDbl(Me.fileCount)
					Me.loadImagePreview((From f In Directory.GetFiles(Me.sourcePath, "*.*") Where Me.extensions.Contains(f.Split(New Char() {"."C}).Last(Of String)().ToLower())f).ToArray(Of String)().FirstOrDefault(Of String)())
                    End If
                    Me.textBox5.Text = Convert.ToString(Me.fileCount)
                Else
                    MessageBox.Show("Folder?")
                End If
            End Sub

            Private Sub TextBox1TextChanged(sender As Object, e As EventArgs)
            End Sub

            Private Sub Button2Click(sender As Object, e As EventArgs)
                Dim folderBrowserDialog As New FolderBrowserDialog()
                If Directory.Exists(Me.targetPath) Then
                    folderBrowserDialog.SelectedPath = Me.targetPath
                End If
                Dim dialogResult__1 As DialogResult = folderBrowserDialog.ShowDialog(Me)
                If dialogResult__1 = DialogResult.OK Then
                    Me.textBox2.Text = folderBrowserDialog.SelectedPath
                    Me.targetPath = folderBrowserDialog.SelectedPath
                Else
                    MessageBox.Show("Folder?")
                End If
            End Sub

            Private Sub Label1Click(sender As Object, e As EventArgs)
            End Sub

            Private Sub RadioButton1CheckedChanged(sender As Object, e As EventArgs)
            End Sub

            Private Sub Label2Click(sender As Object, e As EventArgs)
            End Sub

            Private Sub Button3Click(sender As Object, e As EventArgs)
                If Me.sourcePath <> "empty" AndAlso Me.targetPath <> "empty" Then
                    Me.arguments = ""
                    If Me.checkedListBox1.GetItemCheckState(0).ToString() = "Unchecked" Then
                        Me.arguments = "-nomips "
                    Else
                        Me.arguments = ""
                    End If
                    If Me.radioButton2.Checked Then
                        Me.arguments = Convert.ToString("-repeat ") & Me.arguments
                    Else
                        Me.arguments = Convert.ToString("-clamp ") & Me.arguments
                    End If
                    If Me.checkedListBox1.GetItemCheckState(1).ToString() = "Checked" Then
                        Me.arguments += "-alpha "
                    End If
                    If Me.checkedListBox1.GetItemCheckState(2).ToString() = "Checked" Then
                        Me.arguments += "-normal "
                    End If
                    If Me.checkedListBox1.GetItemCheckState(3).ToString() = "Checked" Then
                        Me.arguments += "-tonormal "
                    End If
                    If Me.checkedListBox1.GetItemCheckState(5).ToString() = "Checked" Then
                        Me.arguments += "-fast "
                    End If
                    If Me.checkedListBox1.GetItemCheckState(6).ToString() = "Checked" Then
                        Me.arguments += "-nocuda "
                    End If
                    Select Case Me.comboBox1.SelectedIndex
                        Case 0
                            Me.arguments = Convert.ToString("-bc1 ") & Me.arguments
                            Exit Select
                        Case 1
                            Me.arguments = Convert.ToString("-rgb ") & Me.arguments
                            Exit Select
                        Case 2
                            Me.arguments = Convert.ToString("-bc1n ") & Me.arguments
                            Exit Select
                        Case 3
                            Me.arguments = Convert.ToString("-bc1a ") & Me.arguments
                            Exit Select
                        Case 4
                            Me.arguments = Convert.ToString("-bc2 ") & Me.arguments
                            Exit Select
                        Case 5
                            Me.arguments = Convert.ToString("-bc3 ") & Me.arguments
                            Exit Select
                        Case 6
                            Me.arguments = Convert.ToString("-bc3n ") & Me.arguments
                            Exit Select
                        Case 7
                            Me.arguments = Convert.ToString("-bc4 ") & Me.arguments
                            Exit Select
                        Case 8
                            Me.arguments = Convert.ToString("-bc5 ") & Me.arguments
                            Exit Select
                    End Select
				Dim array As String() = (From f In Directory.GetFiles(Me.sourcePath, "*.*") Where Me.extensions.Contains(f.Split(New Char() {"."C}).Last(Of String)().ToLower())f).ToArray(Of String)()
                    For i As Integer = 0 To Array.Length - 1
                        Dim text As String = Array(i)
                        Me.loadImagePreview(text)
                        If Me.checkedListBox1.GetItemCheckState(4).ToString() = "Checked" Then
                            Me.loadImagePreviewPow2(text)
                            Dim process As New Process()
                            process.StartInfo.FileName = "bin\convert.exe"
                            process.StartInfo.Arguments = String.Concat(New String() {"""", text, """ -filter Lanczos -sampling-factor 1x1 -quality 90 -resize ", Convert.ToString(Me.PowerOfTwo(Me.image.Width)), "x", Convert.ToString(Me.PowerOfTwo(Me.image.Height)), _
                                "! """, Me.targetPath, "\bufferimage.png"""})
                            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
                            process.StartInfo.UseShellExecute = False
                            process.StartInfo.CreateNoWindow = True
                            process.Start()
                            process.WaitForExit()
                        End If
                        Me.preparedTargetPath = text.Replace(Me.sourcePath, Me.targetPath)
                        Me.preparedTargetPath = Path.ChangeExtension(Me.preparedTargetPath, ".dds")
                        Dim process2 As New Process()
                        process2.StartInfo.FileName = "bin\nvcompress.exe"
                        If Me.checkedListBox1.GetItemCheckState(4).ToString() = "Checked" Then
                            process2.StartInfo.Arguments = String.Concat(New String() {Me.arguments, """", Me.targetPath, "\bufferimage.png"" """, Me.preparedTargetPath, """"})
                        Else
                            process2.StartInfo.Arguments = String.Concat(New String() {Me.arguments, """", text, """ """, Me.preparedTargetPath, """"})
                        End If
                        process2.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
                        process2.StartInfo.UseShellExecute = False
                        If Not Me.checkBox1.Checked Then
                            process2.StartInfo.CreateNoWindow = True
                        End If
                        process2.Start()
                        process2.WaitForExit()
                        Me.i += 1
                        Me.textBox4.Text = text

                        Me.textBox6.Text = Convert.ToString(Convert.ToInt32(CDbl(Me.i) * Me.prozent)) + " %"
                        Me.Refresh()
                    Next
                    If Me.checkedListBox1.GetItemCheckState(4).ToString() = "Checked" Then
                        File.Delete(Me.targetPath & Convert.ToString("\bufferimage.png"))
                    End If
                    Me.textBox6.Text = "100 %"
                    MessageBox.Show(Convert.ToString(Me.i) + " Files processed")
                    Me.textBox6.Text = "0 %"
                    Me.textBox4.Text = ""
                    Me.i = 0
                Else
                    MessageBox.Show("Please choose source and target folder !")
                End If
            End Sub

            Private Function PowerOfTwo(Res As Integer) As Double
                Return Math.Pow(2.0, Math.Ceiling(Math.Log(CDbl(Res), 2.0)))
            End Function

            Private Sub ProgressBar1Click(sender As Object, e As EventArgs)
            End Sub

            Private Sub Label4Click(sender As Object, e As EventArgs)
            End Sub

            Private Sub CheckBox4CheckedChanged(sender As Object, e As EventArgs)
            End Sub

            Private Sub CheckedListBox1SelectedIndexChanged(sender As Object, e As EventArgs)
                If Me.checkedListBox1.GetItemCheckState(4).ToString() = "Checked" Then
                    Me.checkBox2.Visible = False
                    Me.Refresh()
                Else
                    Me.checkBox2.Visible = False
                    Me.Refresh()
                End If
            End Sub

            Private Sub loadImagePreviewPow2(bufferPath As String)
                If Me.pictureBox1.Image IsNot Nothing Then
                    Me.pictureBox1.Image.Dispose()
                End If
                Dim extension As String = Path.GetExtension(bufferPath)
                If extension = ".tga" Then
                    Me.image = TargaImage.LoadTargaImage(bufferPath)
                    Me.pictureBox1.Image = Me.image
                    Me.textBox8.Text = Convert.ToString(Me.PowerOfTwo(Me.image.Height)) + "x" + Convert.ToString(Me.PowerOfTwo(Me.image.Width))
                Else
                    Me.image = System.Drawing.Image.FromFile(bufferPath)
                    Me.pictureBox1.Image = Me.image
                    Me.textBox8.Text = Convert.ToString(Me.PowerOfTwo(Me.image.Height)) + "x" + Convert.ToString(Me.PowerOfTwo(Me.image.Width))
                End If
            End Sub

            Private Sub loadImagePreview(bufferPath As String)
                If Me.checkBox2.Checked Then
                    If Me.pictureBox1.Image IsNot Nothing Then
                        Me.pictureBox1.Image.Dispose()
                    End If
                    Dim extension As String = Path.GetExtension(bufferPath)
                    If extension = ".tga" Then
                        Dim image As System.Drawing.Image = TargaImage.LoadTargaImage(bufferPath)
                        Me.pictureBox1.Image = image
                        Me.textBox3.Text = Convert.ToString(image.Height) + "x" + Convert.ToString(image.Width)
                    Else
                        Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(bufferPath)
                        Me.pictureBox1.Image = image
                        Me.textBox3.Text = Convert.ToString(image.Height) + "x" + Convert.ToString(image.Width)
                    End If
                End If
            End Sub

            Public Function GetSetting(xPath As String, defaultValue As String) As String
                Dim xmlNode As XmlNode = Me.xmlDocument.SelectSingleNode(Convert.ToString("settings/") & xPath)
                Dim result As String
                If xmlNode IsNot Nothing Then
                    result = xmlNode.InnerText
                Else
                    result = defaultValue
                End If
                Return result
            End Function

            Public Sub PutSetting(xPath As String, value As String)
                Dim xmlNode As XmlNode = Me.xmlDocument.SelectSingleNode(Convert.ToString("settings/") & xPath)
                If xmlNode Is Nothing Then
                    xmlNode = Me.createMissingNode(Convert.ToString("settings/") & xPath)
                End If
                xmlNode.InnerText = value
                Me.xmlDocument.Save(Me.documentPath)
            End Sub

            Private Function createMissingNode(xPath As String) As XmlNode
                Dim array As String() = xPath.Split(New Char() {"/"c})
                Dim text As String = ""
                Dim xmlNode As XmlNode = Me.xmlDocument.SelectSingleNode("settings")
                Dim array2 As String() = array
                For i As Integer = 0 To array2.Length - 1
                    Dim text2 As String = array2(i)
                    text += text2
                    Dim xmlNode2 As XmlNode = Me.xmlDocument.SelectSingleNode(text)
                    If xmlNode2 Is Nothing Then
                        Dim expr_6A As XmlNode = xmlNode
                        Dim innerXml As String = expr_6A.InnerXml
                        expr_6A.InnerXml = String.Concat(New String() {innerXml, "<", text2, ">"})
                    End If
                    xmlNode = Me.xmlDocument.SelectSingleNode(text)
                    text += "/"
                Next
                Return xmlNode
            End Function

            Private Sub folderDrop(sender As Object, e As DragEventArgs)
                If e.Data.GetDataPresent(DataFormats.FileDrop) Then
                    Dim array As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop), String())
                    If Directory.Exists(array(0)) Then
                        Me.textBox1.Text = array(0)
                        Me.sourcePath = array(0)
					Me.fileCount = (From f In Directory.GetFiles(Me.sourcePath, "*.*") Where Me.extensions.Contains(f.Split(New Char() {"."C}).Last(Of String)().ToLower())f).ToArray(Of String)().Length
                        If Me.fileCount <> 0 Then
						Me.loadImagePreview((From f In Directory.GetFiles(Me.sourcePath, "*.*") Where Me.extensions.Contains(f.Split(New Char() {"."C}).Last(Of String)().ToLower())f).ToArray(Of String)().FirstOrDefault(Of String)())
                        End If
                        Me.textBox5.Text = Convert.ToString(Me.fileCount)
                        Me.prozent = 100.0 / CDbl(Me.fileCount)
                    End If
                End If
            End Sub

            Private Sub DragEnterSource(sender As Object, e As DragEventArgs)
                If e.Data.GetDataPresent(DataFormats.FileDrop) Then
                    e.Effect = DragDropEffects.Copy
                Else
                    e.Effect = DragDropEffects.None
                End If
            End Sub

            Private Sub targetDragEnter(sender As Object, e As DragEventArgs)
                If e.Data.GetDataPresent(DataFormats.FileDrop) Then
                    e.Effect = DragDropEffects.Copy
                Else
                    e.Effect = DragDropEffects.None
                End If
            End Sub

            Private Sub targetDrop(sender As Object, e As DragEventArgs)
                If e.Data.GetDataPresent(DataFormats.FileDrop) Then
                    Dim array As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop), String())
                    If Directory.Exists(array(0)) Then
                        Me.textBox2.Text = array(0)
                        Me.targetPath = array(0)
                    End If
                End If
            End Sub

            Protected Overrides Sub Dispose(disposing As Boolean)
                If disposing Then
                    If Me.components IsNot Nothing Then
                        Me.components.Dispose()
                    End If
                End If
                MyBase.Dispose(disposing)
            End Sub

            Private Sub InitializeComponent()
                Dim componentResourceManager As New ComponentResourceManager(GetType(MainForm))
                Me.button1 = New Button()
                Me.textBox1 = New TextBox()
                Me.button2 = New Button()
                Me.textBox2 = New TextBox()
                Me.checkedListBox1 = New CheckedListBox()
                Me.label1 = New Label()
                Me.comboBox1 = New ComboBox()
                Me.label2 = New Label()
                Me.radioButton1 = New RadioButton()
                Me.radioButton2 = New RadioButton()
                Me.button3 = New Button()
                Me.textBox4 = New TextBox()
                Me.textBox5 = New TextBox()
                Me.label3 = New Label()
                Me.textBox6 = New TextBox()
                Me.panel1 = New Panel()
                Me.checkBox1 = New CheckBox()
                Me.label4 = New Label()
                Me.pictureBox1 = New PictureBox()
                Me.textBox3 = New TextBox()
                Me.checkBox2 = New CheckBox()
                Me.textBox8 = New TextBox()
                Me.panel1.SuspendLayout()
                DirectCast(Me.pictureBox1, ISupportInitialize).BeginInit()
                MyBase.SuspendLayout()
                Me.button1.Location = New System.Drawing.Point(23, 23)
                Me.button1.Margin = New Padding(2)
                Me.button1.Name = "button1"
                Me.button1.Size = New System.Drawing.Size(85, 29)
                Me.button1.TabIndex = 0
                Me.button1.Text = "Source Folder"
                Me.button1.UseVisualStyleBackColor = True
                Me.button1.Click += New EventHandler(AddressOf Me.Button1Click)
                Me.textBox1.AllowDrop = True
                Me.textBox1.BackColor = System.Drawing.SystemColors.HighlightText
                Me.textBox1.Location = New System.Drawing.Point(111, 29)
                Me.textBox1.Margin = New Padding(2)
                Me.textBox1.Name = "textBox1"
                Me.textBox1.Size = New System.Drawing.Size(334, 20)
                Me.textBox1.TabIndex = 1
                Me.textBox1.TextChanged += New EventHandler(AddressOf Me.TextBox1TextChanged)
                Me.textBox1.DragDrop += New DragEventHandler(AddressOf Me.folderDrop)
                Me.textBox1.DragEnter += New DragEventHandler(AddressOf Me.DragEnterSource)
                Me.button2.Location = New System.Drawing.Point(23, 58)
                Me.button2.Margin = New Padding(2)
                Me.button2.Name = "button2"
                Me.button2.Size = New System.Drawing.Size(85, 29)
                Me.button2.TabIndex = 2
                Me.button2.Text = "Target Folder"
                Me.button2.UseVisualStyleBackColor = True
                Me.button2.Click += New EventHandler(AddressOf Me.Button2Click)
                Me.textBox2.AllowDrop = True
                Me.textBox2.BackColor = System.Drawing.SystemColors.HighlightText
                Me.textBox2.Location = New System.Drawing.Point(111, 64)
                Me.textBox2.Margin = New Padding(2)
                Me.textBox2.Name = "textBox2"
                Me.textBox2.Size = New System.Drawing.Size(334, 20)
                Me.textBox2.TabIndex = 3
                Me.textBox2.DragDrop += New DragEventHandler(AddressOf Me.targetDrop)
                Me.textBox2.DragEnter += New DragEventHandler(AddressOf Me.targetDragEnter)
                Me.checkedListBox1.BackColor = System.Drawing.Color.Gainsboro
                Me.checkedListBox1.BorderStyle = BorderStyle.None
                Me.checkedListBox1.CheckOnClick = True
                Me.checkedListBox1.FormattingEnabled = True
                Me.checkedListBox1.Items.AddRange(New Object() {"Mipmaps", "Alpha", "Normal", "toNormalMap", "Resize Pow2", "Fast", _
                    "No CUDA"})
                Me.checkedListBox1.Location = New System.Drawing.Point(190, 123)
                Me.checkedListBox1.Margin = New Padding(2)
                Me.checkedListBox1.Name = "checkedListBox1"
                Me.checkedListBox1.Size = New System.Drawing.Size(114, 105)
                Me.checkedListBox1.TabIndex = 4
                Me.checkedListBox1.SelectedIndexChanged += New EventHandler(AddressOf Me.CheckedListBox1SelectedIndexChanged)
                Me.label1.BackColor = System.Drawing.Color.Gainsboro
                Me.label1.ForeColor = System.Drawing.SystemColors.ControlDarkDark
                Me.label1.Location = New System.Drawing.Point(190, 107)
                Me.label1.Margin = New Padding(2, 0, 2, 0)
                Me.label1.Name = "label1"
                Me.label1.Size = New System.Drawing.Size(60, 13)
                Me.label1.TabIndex = 5
                Me.label1.Text = "Options"
                Me.label1.Click += New EventHandler(AddressOf Me.Label1Click)
                Me.comboBox1.FormattingEnabled = True
                Me.comboBox1.Items.AddRange(New Object() {"DXT1", "RGBA", "DXT1NormalMap", "DXT1BinaryAlpha", "DXT3", "DXT5", _
                    "DXT5NormalMap", "ATI1", "ATI2/3DC"})
                Me.comboBox1.Location = New System.Drawing.Point(39, 123)
                Me.comboBox1.Margin = New Padding(2)
                Me.comboBox1.Name = "comboBox1"
                Me.comboBox1.Size = New System.Drawing.Size(130, 21)
                Me.comboBox1.TabIndex = 10
                Me.label2.BackColor = System.Drawing.Color.Gainsboro
                Me.label2.ForeColor = System.Drawing.SystemColors.ControlDarkDark
                Me.label2.Location = New System.Drawing.Point(39, 107)
                Me.label2.Margin = New Padding(2, 0, 2, 0)
                Me.label2.Name = "label2"
                Me.label2.Size = New System.Drawing.Size(128, 13)
                Me.label2.TabIndex = 11
                Me.label2.Text = "Output Format"
                Me.label2.Click += New EventHandler(AddressOf Me.Label2Click)
                Me.radioButton1.Location = New System.Drawing.Point(16, 49)
                Me.radioButton1.Margin = New Padding(2)
                Me.radioButton1.Name = "radioButton1"
                Me.radioButton1.Size = New System.Drawing.Size(62, 19)
                Me.radioButton1.TabIndex = 12
                Me.radioButton1.TabStop = True
                Me.radioButton1.Text = "Clamp"
                Me.radioButton1.UseVisualStyleBackColor = True
                Me.radioButton2.Location = New System.Drawing.Point(16, 65)
                Me.radioButton2.Margin = New Padding(2)
                Me.radioButton2.Name = "radioButton2"
                Me.radioButton2.Size = New System.Drawing.Size(62, 22)
                Me.radioButton2.TabIndex = 13
                Me.radioButton2.TabStop = True
                Me.radioButton2.Text = "Repeat"
                Me.radioButton2.UseVisualStyleBackColor = True
                Me.button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.15584F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
                Me.button3.Location = New System.Drawing.Point(310, 96)
                Me.button3.Margin = New Padding(2)
                Me.button3.Name = "button3"
                Me.button3.Size = New System.Drawing.Size(205, 139)
                Me.button3.TabIndex = 14
                Me.button3.Text = "Convert"
                Me.button3.UseVisualStyleBackColor = True
                Me.button3.Click += New EventHandler(AddressOf Me.Button3Click)
                Me.textBox4.BackColor = System.Drawing.SystemColors.HighlightText
                Me.textBox4.Enabled = False
                Me.textBox4.Location = New System.Drawing.Point(23, 242)
                Me.textBox4.Margin = New Padding(2)
                Me.textBox4.Name = "textBox4"
                Me.textBox4.Size = New System.Drawing.Size(447, 20)
                Me.textBox4.TabIndex = 16
                Me.textBox5.BackColor = System.Drawing.SystemColors.HighlightText
                Me.textBox5.Enabled = False
                Me.textBox5.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.948052F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
                Me.textBox5.Location = New System.Drawing.Point(447, 29)
                Me.textBox5.Margin = New Padding(2)
                Me.textBox5.Name = "textBox5"
                Me.textBox5.Size = New System.Drawing.Size(68, 19)
                Me.textBox5.TabIndex = 18
                Me.textBox5.TextAlign = HorizontalAlignment.Right
                Me.label3.ForeColor = System.Drawing.SystemColors.ControlDarkDark
                Me.label3.Location = New System.Drawing.Point(458, 50)
                Me.label3.Margin = New Padding(2, 0, 2, 0)
                Me.label3.Name = "label3"
                Me.label3.Size = New System.Drawing.Size(57, 17)
                Me.label3.TabIndex = 19
                Me.label3.Text = "FileCount"
                Me.label3.TextAlign = System.Drawing.ContentAlignment.TopRight
                Me.textBox6.BackColor = System.Drawing.SystemColors.HighlightText
                Me.textBox6.Enabled = False
                Me.textBox6.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
                Me.textBox6.Location = New System.Drawing.Point(472, 242)
                Me.textBox6.Margin = New Padding(2)
                Me.textBox6.Name = "textBox6"
                Me.textBox6.Size = New System.Drawing.Size(43, 20)
                Me.textBox6.TabIndex = 20
                Me.textBox6.TextAlign = HorizontalAlignment.Right
                Me.panel1.BackColor = System.Drawing.Color.Gainsboro
                Me.panel1.BorderStyle = BorderStyle.FixedSingle
                Me.panel1.Controls.Add(Me.radioButton1)
                Me.panel1.Controls.Add(Me.radioButton2)
                Me.panel1.Location = New System.Drawing.Point(23, 96)
                Me.panel1.Margin = New Padding(2)
                Me.panel1.Name = "panel1"
                Me.panel1.Size = New System.Drawing.Size(284, 140)
                Me.panel1.TabIndex = 21
                Me.checkBox1.ForeColor = System.Drawing.Color.Gray
                Me.checkBox1.Location = New System.Drawing.Point(518, 286)
                Me.checkBox1.Margin = New Padding(2)
                Me.checkBox1.Name = "checkBox1"
                Me.checkBox1.Size = New System.Drawing.Size(197, 18)
                Me.checkBox1.TabIndex = 22
                Me.checkBox1.Text = "Show Messages"
                Me.checkBox1.UseVisualStyleBackColor = True
                Me.label4.ForeColor = System.Drawing.Color.LightGray
                Me.label4.Location = New System.Drawing.Point(23, 286)
                Me.label4.Name = "label4"
                Me.label4.Size = New System.Drawing.Size(263, 15)
                Me.label4.TabIndex = 23
                Me.label4.Text = "GUI for NVIDIA Texture Tools 2.0 // wirmachenbunt"
                Me.pictureBox1.BackColor = System.Drawing.Color.Gainsboro
                Me.pictureBox1.BackgroundImage = DirectCast(componentResourceManager.GetObject("pictureBox1.BackgroundImage"), System.Drawing.Image)
                Me.pictureBox1.BorderStyle = BorderStyle.FixedSingle
                Me.pictureBox1.InitialImage = DirectCast(componentResourceManager.GetObject("pictureBox1.InitialImage"), System.Drawing.Image)
                Me.pictureBox1.Location = New System.Drawing.Point(518, 29)
                Me.pictureBox1.Name = "pictureBox1"
                Me.pictureBox1.Size = New System.Drawing.Size(223, 233)
                Me.pictureBox1.SizeMode = PictureBoxSizeMode.Zoom
                Me.pictureBox1.TabIndex = 24
                Me.pictureBox1.TabStop = False
                Me.textBox3.BackColor = System.Drawing.SystemColors.Control
                Me.textBox3.BorderStyle = BorderStyle.None
                Me.textBox3.Enabled = False
                Me.textBox3.ForeColor = System.Drawing.SystemColors.ScrollBar
                Me.textBox3.Location = New System.Drawing.Point(518, 14)
                Me.textBox3.Margin = New Padding(2)
                Me.textBox3.Name = "textBox3"
                Me.textBox3.Size = New System.Drawing.Size(94, 13)
                Me.textBox3.TabIndex = 24
                Me.checkBox2.Checked = True
                Me.checkBox2.CheckState = CheckState.Checked
                Me.checkBox2.ForeColor = System.Drawing.Color.Gray
                Me.checkBox2.Location = New System.Drawing.Point(518, 267)
                Me.checkBox2.Margin = New Padding(2)
                Me.checkBox2.Name = "checkBox2"
                Me.checkBox2.Size = New System.Drawing.Size(197, 19)
                Me.checkBox2.TabIndex = 25
                Me.checkBox2.Text = "Preview (a bit slower)"
                Me.checkBox2.UseVisualStyleBackColor = True
                Me.textBox8.BackColor = System.Drawing.SystemColors.Control
                Me.textBox8.BorderStyle = BorderStyle.None
                Me.textBox8.Enabled = False
                Me.textBox8.ForeColor = System.Drawing.SystemColors.ScrollBar
                Me.textBox8.Location = New System.Drawing.Point(647, 14)
                Me.textBox8.Margin = New Padding(2)
                Me.textBox8.Name = "textBox8"
                Me.textBox8.Size = New System.Drawing.Size(94, 13)
                Me.textBox8.TabIndex = 26
                Me.textBox8.TextAlign = HorizontalAlignment.Right
                MyBase.AutoScaleDimensions = New System.Drawing.SizeF(6.0F, 13.0F)
                MyBase.AutoScaleMode = AutoScaleMode.Font
                Me.BackColor = System.Drawing.SystemColors.Control
                MyBase.ClientSize = New System.Drawing.Size(763, 312)
                MyBase.Controls.Add(Me.textBox8)
                MyBase.Controls.Add(Me.checkBox2)
                MyBase.Controls.Add(Me.textBox3)
                MyBase.Controls.Add(Me.pictureBox1)
                MyBase.Controls.Add(Me.label4)
                MyBase.Controls.Add(Me.checkBox1)
                MyBase.Controls.Add(Me.textBox6)
                MyBase.Controls.Add(Me.label3)
                MyBase.Controls.Add(Me.textBox5)
                MyBase.Controls.Add(Me.textBox4)
                MyBase.Controls.Add(Me.button3)
                MyBase.Controls.Add(Me.label2)
                MyBase.Controls.Add(Me.comboBox1)
                MyBase.Controls.Add(Me.label1)
                MyBase.Controls.Add(Me.checkedListBox1)
                MyBase.Controls.Add(Me.textBox2)
                MyBase.Controls.Add(Me.button2)
                MyBase.Controls.Add(Me.textBox1)
                MyBase.Controls.Add(Me.button1)
                MyBase.Controls.Add(Me.panel1)
                MyBase.FormBorderStyle = FormBorderStyle.FixedToolWindow
                MyBase.Icon = DirectCast(componentResourceManager.GetObject("$this.Icon"), System.Drawing.Icon)
                MyBase.Margin = New Padding(2)
                MyBase.Name = "MainForm"
                Me.Text = "DDS Converter 1.4"
                MyBase.FormClosing += New FormClosingEventHandler(AddressOf Me.MainformClosing)
                MyBase.Load += New EventHandler(AddressOf Me.MainFormLoad)
                Me.panel1.ResumeLayout(False)
                DirectCast(Me.pictureBox1, ISupportInitialize).EndInit()
                MyBase.ResumeLayout(False)
                MyBase.PerformLayout()
            End Sub
            End Namespace
    End Class

End Class


What I have tried:

I am new at C# and Visual Basic
Posted
Updated 17-Nov-16 20:27pm
Comments
Matt T Heffron 17-Nov-16 17:56pm    
(For starters, your nested classes declaration looks a bit strange...)
Why are you trying to put the Namespace inside the MainForm?
It is not possible to change the namespace for part of a type (class) declaration. (What would that even mean?)
Member 12856880 17-Nov-16 17:58pm    
So what should I do? Can you fix my code please?
[no name] 17-Nov-16 18:25pm    
Why can't you fix it? Move the namespace statement to the file or namespace level just like the error message tells you to.

1 solution

As Matt is telling
move

Namespace NVCompressGUI


after last import statement and above class statement like below


VB.NET
Imports System.Xml 

Namespace NVCompressGUI 

Public Class Form1 


and also move

End Namespace


to the bottom as last line
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900