Files
crypters-scode/scode (Elm0D Simple Crypter Example/Stb/Explorer1.vb
T
2026-08-27 11:04:21 -06:00

193 lines
8.0 KiB
VB.net

Imports System.Diagnostics
Imports System.Windows.Forms
Public Class Explorer1
Private Sub Explorer1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set up the UI
SetUpListViewColumns()
LoadTree()
End Sub
Private Sub LoadTree()
' TODO: Add code to add items to the treeview
Dim tvRoot As TreeNode
Dim tvNode As TreeNode
tvRoot = Me.TreeView.Nodes.Add("Root")
tvNode = tvRoot.Nodes.Add("TreeItem1")
tvNode = tvRoot.Nodes.Add("TreeItem2")
tvNode = tvRoot.Nodes.Add("TreeItem3")
End Sub
Private Sub LoadListView()
' TODO: Add code to add items to the listview based on the selected item in the treeview
Dim lvItem As ListViewItem
ListView.Items.Clear()
lvItem = ListView.Items.Add("ListViewItem1")
lvItem.ImageKey = "Graph1"
lvItem.SubItems.AddRange(New String() {"Column2", "Column3"})
lvItem = ListView.Items.Add("ListViewItem2")
lvItem.ImageKey = "Graph2"
lvItem.SubItems.AddRange(New String() {"Column2", "Column3"})
lvItem = ListView.Items.Add("ListViewItem3")
lvItem.ImageKey = "Graph3"
lvItem.SubItems.AddRange(New String() {"Column2", "Column3"})
End Sub
Private Sub SetUpListViewColumns()
' TODO: Add code to set up listview columns
Dim lvColumnHeader As ColumnHeader
' Setting Column widths applies only to the current view, so this line
' explicitly sets the ListView to be showing the SmallIcon view
' before setting the column width
SetView(View.SmallIcon)
lvColumnHeader = ListView.Columns.Add("Column1")
' Set the SmallIcon view column width large enough so that the items
' do not overlap
' Note that the second and third column do not appear in SmallIcon
' view, so there is no need to set those while in SmallIcon view
lvColumnHeader.Width = 90
' Change the view to Details and set up the appropriate column
' widths for the Details view differently than SmallIcon view
SetView(View.Details)
' The first column needs to be slightly larger in Details view than it
' was for SmallIcon view, and Column2 and Column3 need explicit sizes
' set for Details view
lvColumnHeader.Width = 100
lvColumnHeader = ListView.Columns.Add("Column2")
lvColumnHeader.Width = 70
lvColumnHeader = ListView.Columns.Add("Column3")
lvColumnHeader.Width = 70
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
'Close this form
Me.Close()
End Sub
Private Sub ToolBarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolBarToolStripMenuItem.Click
'Toggle the visibility of the toolstrip and also the checked state of the associated menu item
ToolBarToolStripMenuItem.Checked = Not ToolBarToolStripMenuItem.Checked
ToolStrip.Visible = ToolBarToolStripMenuItem.Checked
End Sub
Private Sub StatusBarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusBarToolStripMenuItem.Click
'Toggle the visibility of the statusstrip and also the checked state of the associated menu item
StatusBarToolStripMenuItem.Checked = Not StatusBarToolStripMenuItem.Checked
StatusStrip.Visible = StatusBarToolStripMenuItem.Checked
End Sub
'Change whether or not the folders pane is visible
Private Sub ToggleFoldersVisible()
'First toggle the checked state of the associated menu item
FoldersToolStripMenuItem.Checked = Not FoldersToolStripMenuItem.Checked
'Change the Folders toolbar button to be in sync
FoldersToolStripButton.Checked = FoldersToolStripMenuItem.Checked
' Collapse the Panel containing the TreeView.
Me.SplitContainer.Panel1Collapsed = Not FoldersToolStripMenuItem.Checked
End Sub
Private Sub FoldersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FoldersToolStripMenuItem.Click
ToggleFoldersVisible()
End Sub
Private Sub FoldersToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FoldersToolStripButton.Click
ToggleFoldersVisible()
End Sub
Private Sub SetView(ByVal View As System.Windows.Forms.View)
'Figure out which menu item should be checked
Dim MenuItemToCheck As ToolStripMenuItem = Nothing
Select Case View
Case View.Details
MenuItemToCheck = DetailsToolStripMenuItem
Case View.LargeIcon
MenuItemToCheck = LargeIconsToolStripMenuItem
Case View.List
MenuItemToCheck = ListToolStripMenuItem
Case View.SmallIcon
MenuItemToCheck = SmallIconsToolStripMenuItem
Case View.Tile
MenuItemToCheck = TileToolStripMenuItem
Case Else
Debug.Fail("Unexpected View")
View = View.Details
MenuItemToCheck = DetailsToolStripMenuItem
End Select
'Check the appropriate menu item and deselect all others under the Views menu
For Each MenuItem As ToolStripMenuItem In ListViewToolStripButton.DropDownItems
If MenuItem Is MenuItemToCheck Then
MenuItem.Checked = True
Else
MenuItem.Checked = False
End If
Next
'Finally, set the view requested
ListView.View = View
End Sub
Private Sub ListToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListToolStripMenuItem.Click
SetView(View.List)
End Sub
Private Sub DetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DetailsToolStripMenuItem.Click
SetView(View.Details)
End Sub
Private Sub LargeIconsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LargeIconsToolStripMenuItem.Click
SetView(View.LargeIcon)
End Sub
Private Sub SmallIconsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SmallIconsToolStripMenuItem.Click
SetView(View.SmallIcon)
End Sub
Private Sub TileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileToolStripMenuItem.Click
SetView(View.Tile)
End Sub
Private Sub OpenToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "Text Files (*.txt)|*.txt"
OpenFileDialog.ShowDialog(Me)
Dim FileName As String = OpenFileDialog.FileName
' TODO: Add code to open the file
End Sub
Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveAsToolStripMenuItem.Click
Dim SaveFileDialog As New SaveFileDialog
SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Text Files (*.txt)|*.txt"
SaveFileDialog.ShowDialog(Me)
Dim FileName As String = SaveFileDialog.FileName
' TODO: Add code here to save the current contents of the form to a file.
End Sub
Private Sub TreeView_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView.AfterSelect
' TODO: Add code to change the listview contents based on the currently-selected node of the treeview
LoadListView()
End Sub
End Class