From 525c7d3ec3ad875a866812e10a7bbf8a0c2d2140 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Sun, 29 Nov 2015 11:39:25 -0600 Subject: [PATCH] Added context menu and game manager tweaks --- GBM/Forms/frmGameManager.Designer.vb | 10 +-- GBM/Forms/frmIncludeExclude.Designer.vb | 49 ++++++++++++--- GBM/Forms/frmIncludeExclude.resx | 5 +- GBM/Forms/frmIncludeExclude.vb | 84 ++++++++++++++++++------- 4 files changed, 115 insertions(+), 33 deletions(-) diff --git a/GBM/Forms/frmGameManager.Designer.vb b/GBM/Forms/frmGameManager.Designer.vb index 41414ec..8cc94e2 100644 --- a/GBM/Forms/frmGameManager.Designer.vb +++ b/GBM/Forms/frmGameManager.Designer.vb @@ -163,7 +163,7 @@ Partial Class frmGameManager ' 'btnExclude ' - Me.btnExclude.Location = New System.Drawing.Point(498, 123) + Me.btnExclude.Location = New System.Drawing.Point(69, 122) Me.btnExclude.Name = "btnExclude" Me.btnExclude.Size = New System.Drawing.Size(30, 20) Me.btnExclude.TabIndex = 13 @@ -172,7 +172,7 @@ Partial Class frmGameManager ' 'btnInclude ' - Me.btnInclude.Location = New System.Drawing.Point(498, 97) + Me.btnInclude.Location = New System.Drawing.Point(69, 97) Me.btnInclude.Name = "btnInclude" Me.btnInclude.Size = New System.Drawing.Size(30, 20) Me.btnInclude.TabIndex = 11 @@ -254,17 +254,19 @@ Partial Class frmGameManager ' 'txtExclude ' - Me.txtExclude.Location = New System.Drawing.Point(69, 123) + Me.txtExclude.Location = New System.Drawing.Point(105, 123) Me.txtExclude.Name = "txtExclude" Me.txtExclude.Size = New System.Drawing.Size(423, 20) Me.txtExclude.TabIndex = 12 + Me.txtExclude.Visible = False ' 'txtFileType ' - Me.txtFileType.Location = New System.Drawing.Point(69, 97) + Me.txtFileType.Location = New System.Drawing.Point(105, 97) Me.txtFileType.Name = "txtFileType" Me.txtFileType.Size = New System.Drawing.Size(423, 20) Me.txtFileType.TabIndex = 10 + Me.txtFileType.Visible = False ' 'chkTimeStamp ' diff --git a/GBM/Forms/frmIncludeExclude.Designer.vb b/GBM/Forms/frmIncludeExclude.Designer.vb index bbcf39f..676159e 100644 --- a/GBM/Forms/frmIncludeExclude.Designer.vb +++ b/GBM/Forms/frmIncludeExclude.Designer.vb @@ -31,12 +31,17 @@ Partial Class frmIncludeExclude Me.txtRootFolder = New System.Windows.Forms.TextBox() Me.btnBrowse = New System.Windows.Forms.Button() Me.lstBuilder = New System.Windows.Forms.ListView() + Me.cmsItems = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.cmsEdit = New System.Windows.Forms.ToolStripMenuItem() + Me.cmsRemove = New System.Windows.Forms.ToolStripMenuItem() + Me.cmsAdd = New System.Windows.Forms.ToolStripMenuItem() Me.btnRemove = New System.Windows.Forms.Button() Me.btnAdd = New System.Windows.Forms.Button() Me.grpFileOptions = New System.Windows.Forms.GroupBox() Me.optFileTypes = New System.Windows.Forms.RadioButton() Me.optIndividualFiles = New System.Windows.Forms.RadioButton() Me.lblItems = New System.Windows.Forms.Label() + Me.cmsItems.SuspendLayout() Me.grpFileOptions.SuspendLayout() Me.SuspendLayout() ' @@ -82,13 +87,13 @@ Partial Class frmIncludeExclude Me.txtRootFolder.Location = New System.Drawing.Point(12, 12) Me.txtRootFolder.Name = "txtRootFolder" Me.txtRootFolder.ReadOnly = True - Me.txtRootFolder.Size = New System.Drawing.Size(194, 20) + Me.txtRootFolder.Size = New System.Drawing.Size(214, 20) Me.txtRootFolder.TabIndex = 0 Me.txtRootFolder.TabStop = False ' 'btnBrowse ' - Me.btnBrowse.Location = New System.Drawing.Point(212, 12) + Me.btnBrowse.Location = New System.Drawing.Point(232, 12) Me.btnBrowse.Name = "btnBrowse" Me.btnBrowse.Size = New System.Drawing.Size(30, 20) Me.btnBrowse.TabIndex = 0 @@ -97,6 +102,7 @@ Partial Class frmIncludeExclude ' 'lstBuilder ' + Me.lstBuilder.ContextMenuStrip = Me.cmsItems Me.lstBuilder.LabelEdit = True Me.lstBuilder.Location = New System.Drawing.Point(322, 38) Me.lstBuilder.Name = "lstBuilder" @@ -106,13 +112,37 @@ Partial Class frmIncludeExclude Me.lstBuilder.UseCompatibleStateImageBehavior = False Me.lstBuilder.View = System.Windows.Forms.View.List ' + 'cmsItems + ' + Me.cmsItems.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.cmsEdit, Me.cmsRemove, Me.cmsAdd}) + Me.cmsItems.Name = "cmsItems" + Me.cmsItems.Size = New System.Drawing.Size(169, 70) + ' + 'cmsEdit + ' + Me.cmsEdit.Name = "cmsEdit" + Me.cmsEdit.Size = New System.Drawing.Size(168, 22) + Me.cmsEdit.Text = "Edit" + ' + 'cmsRemove + ' + Me.cmsRemove.Name = "cmsRemove" + Me.cmsRemove.Size = New System.Drawing.Size(168, 22) + Me.cmsRemove.Text = "Remove" + ' + 'cmsAdd + ' + Me.cmsAdd.Name = "cmsAdd" + Me.cmsAdd.Size = New System.Drawing.Size(168, 22) + Me.cmsAdd.Text = "Add Custom Item" + ' 'btnRemove ' Me.btnRemove.Location = New System.Drawing.Point(268, 201) Me.btnRemove.Name = "btnRemove" Me.btnRemove.Size = New System.Drawing.Size(48, 23) Me.btnRemove.TabIndex = 4 - Me.btnRemove.Text = "< <" + Me.btnRemove.Text = "<" Me.btnRemove.UseVisualStyleBackColor = True ' 'btnAdd @@ -121,7 +151,7 @@ Partial Class frmIncludeExclude Me.btnAdd.Name = "btnAdd" Me.btnAdd.Size = New System.Drawing.Size(48, 23) Me.btnAdd.TabIndex = 3 - Me.btnAdd.Text = "> >" + Me.btnAdd.Text = ">" Me.btnAdd.UseVisualStyleBackColor = True ' 'grpFileOptions @@ -159,12 +189,12 @@ Partial Class frmIncludeExclude ' 'lblItems ' - Me.lblItems.AutoSize = True - Me.lblItems.Location = New System.Drawing.Point(319, 16) + Me.lblItems.Location = New System.Drawing.Point(322, 16) Me.lblItems.Name = "lblItems" - Me.lblItems.Size = New System.Drawing.Size(32, 13) + Me.lblItems.Size = New System.Drawing.Size(250, 13) Me.lblItems.TabIndex = 14 Me.lblItems.Text = "Items" + Me.lblItems.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'frmIncludeExclude ' @@ -188,6 +218,7 @@ Partial Class frmIncludeExclude Me.ShowIcon = False Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Include / Exclude Builder" + Me.cmsItems.ResumeLayout(False) Me.grpFileOptions.ResumeLayout(False) Me.grpFileOptions.PerformLayout() Me.ResumeLayout(False) @@ -207,4 +238,8 @@ Partial Class frmIncludeExclude Friend WithEvents optFileTypes As System.Windows.Forms.RadioButton Friend WithEvents optIndividualFiles As System.Windows.Forms.RadioButton Friend WithEvents lblItems As System.Windows.Forms.Label + Friend WithEvents cmsItems As System.Windows.Forms.ContextMenuStrip + Friend WithEvents cmsEdit As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents cmsRemove As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents cmsAdd As System.Windows.Forms.ToolStripMenuItem End Class diff --git a/GBM/Forms/frmIncludeExclude.resx b/GBM/Forms/frmIncludeExclude.resx index 636e792..b26b3df 100644 --- a/GBM/Forms/frmIncludeExclude.resx +++ b/GBM/Forms/frmIncludeExclude.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAB6 - CQAAAk1TRnQBSQFMAgEBAwEAAVABAAFQAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CQAAAk1TRnQBSQFMAgEBAwEAAZABAAGQAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -168,4 +168,7 @@ AQcBgAF/AgAC/wHwAR8BgAH/AgAC/wH4AT8C/wIACw== + + 118, 17 + \ No newline at end of file diff --git a/GBM/Forms/frmIncludeExclude.vb b/GBM/Forms/frmIncludeExclude.vb index 3b08fcc..7551d9f 100644 --- a/GBM/Forms/frmIncludeExclude.vb +++ b/GBM/Forms/frmIncludeExclude.vb @@ -33,7 +33,7 @@ Public Class frmIncludeExclude End Set End Property - Private Sub BuildBranch(ByVal sDirectory As String, ByVal oNode As TreeNode, ByVal bIsDriveRoot As Boolean) + Private Sub BuildBranch(ByVal sDirectory As String, ByVal oNode As TreeNode) Dim sFolders As String() Dim sFiles As String() Dim oChild As TreeNode @@ -49,13 +49,9 @@ Public Class frmIncludeExclude sFiles = Directory.GetFiles(sDirectory) If sFolders.Length <> 0 Then - For Each sFolder As String In sFolders - If bIsDriveRoot Then - oChild = New TreeNode(sFolder.Replace(sDirectory, String.Empty), 0, 0) - Else - oChild = New TreeNode(sFolder.Replace(sDirectory & "\", String.Empty), 0, 0) - End If - oChild.Name = sFolder + For Each sFolder As String In sFolders + oChild = New TreeNode(sFolder.Replace(sDirectory, String.Empty).TrimStart("\"), 0, 0) + oChild.Name = sFolder oChild.Tag = 0 oNode.Nodes.Add(oChild) oPlaceHolder = New TreeNode("GBM_Tree_Placeholder") @@ -65,12 +61,8 @@ Public Class frmIncludeExclude End If If sFiles.Length <> 0 Then - For Each sFile As String In sFiles - If bIsDriveRoot Then - oChild = New TreeNode(sFile.Replace(sDirectory, String.Empty), 1, 1) - Else - oChild = New TreeNode(sFile.Replace(sDirectory & "\", String.Empty), 1, 1) - End If + For Each sFile As String In sFiles + oChild = New TreeNode(sFile.Replace(sDirectory, String.Empty).TrimStart("\"), 1, 1) oChild.Tag = 1 oNode.Nodes.Add(oChild) Next @@ -88,20 +80,17 @@ Public Class frmIncludeExclude Private Sub BuildTrunk() Dim oRootNode As TreeNode - Dim bIsDriveRoot As Boolean If Path.GetPathRoot(txtRootFolder.Text) = txtRootFolder.Text Then oRootNode = New TreeNode(txtRootFolder.Text, 0, 0) - bIsDriveRoot = True Else oRootNode = New TreeNode(Path.GetFileName(txtRootFolder.Text), 0, 0) - bIsDriveRoot = False End If treFiles.Nodes.Clear() oRootNode.Name = "Root" treFiles.Nodes.Add(oRootNode) - BuildBranch(txtRootFolder.Text, oRootNode, bIsDriveRoot) + BuildBranch(txtRootFolder.Text, oRootNode) End Sub Private Sub RootPathBrowse() @@ -195,6 +184,24 @@ Public Class frmIncludeExclude Next End Sub + Private Sub IdentifyEntry(ByRef oListItem As ListViewItem, ByVal sNewLabel As String) + Dim iType As Integer = 1 + + If sNewLabel.Contains("*") Then + iType = 2 + Else + If txtRootFolder.Text <> String.Empty Then + If Directory.Exists(txtRootFolder.Text & "\" & sNewLabel) Then + iType = 0 + Else + iType = 1 + End If + End If + End If + + oListItem.ImageIndex = iType + End Sub + Private Sub CreateNewBuilderString() Dim sTempString As String = String.Empty @@ -208,12 +215,12 @@ Public Class frmIncludeExclude End Sub Private Sub frmIncludeExclude_Load(sender As Object, e As EventArgs) Handles MyBase.Load - Me.Text = FormName & " Builder" + Me.Text = FormName & " Builder" txtRootFolder.Text = RootFolder optFileTypes.Checked = True lblItems.Text = FormName & " Items" If BuilderString <> String.Empty Then ParseBuilderString() - If txtRootFolder.Text <> String.Empty Then BuildTrunk() + If txtRootFolder.Text <> String.Empty Then BuildTrunk() End Sub Private Sub frmIncludeExclude_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown @@ -239,7 +246,7 @@ Public Class frmIncludeExclude Private Sub treFiles_BeforeExpand(sender As Object, e As TreeViewCancelEventArgs) Handles treFiles.BeforeExpand If Not e.Node.Name = "Root" Then - BuildBranch(e.Node.Name, e.Node, False) + BuildBranch(e.Node.Name, e.Node) End If End Sub @@ -250,4 +257,39 @@ Public Class frmIncludeExclude Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click RemoveItem() End Sub + + Private Sub cmsItems_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles cmsItems.Opening + If lstBuilder.SelectedItems.Count = 0 Then + cmsEdit.Visible = False + cmsRemove.Visible = False + cmsAdd.Visible = True + Else + cmsEdit.Visible = True + cmsRemove.Visible = True + cmsAdd.Visible = False + End If + End Sub + + Private Sub cmsEdit_Click(sender As Object, e As EventArgs) Handles cmsEdit.Click + If lstBuilder.SelectedItems.Count > 0 Then + lstBuilder.SelectedItems(0).BeginEdit() + End If + End Sub + + Private Sub cmsRemove_Click(sender As Object, e As EventArgs) Handles cmsRemove.Click + RemoveItem() + End Sub + + Private Sub cmsAdd_Click(sender As Object, e As EventArgs) Handles cmsAdd.Click + Dim oNewItem As New ListViewItem("Custom Item", 1) + oNewItem.Selected = True + lstBuilder.Items.Add(oNewItem) + lstBuilder.SelectedItems(0).BeginEdit() + End Sub + + Private Sub lstBuilder_AfterLabelEdit(sender As Object, e As LabelEditEventArgs) Handles lstBuilder.AfterLabelEdit + If Not e.Label Is Nothing Then + IdentifyEntry(lstBuilder.Items(e.Item), e.Label) + End If + End Sub End Class \ No newline at end of file