Skip to content

Commit e3d1b88

Browse files
committed
try to load in explorer view
1 parent 2c440ac commit e3d1b88

5 files changed

Lines changed: 128 additions & 90 deletions

File tree

src/viewers/HDSViewer/FormExplorer.Designer.vb

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,74 @@
1-
Public Class FormExplorer
1+
Imports Galaxy.Data.JSON
2+
Imports Galaxy.Data.JSON.Models
3+
Imports Microsoft.VisualBasic.DataStorage.HDSPack.FileSystem
24

5+
Public Class FormExplorer
6+
7+
Dim WithEvents packTree As JsonViewer
8+
9+
Friend viewer As FormViewer
10+
11+
Private Sub FormExplorer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
12+
packTree = New JsonViewer
13+
packTree.Dock = DockStyle.Fill
14+
15+
Call Controls.Add(packTree)
16+
End Sub
17+
18+
Public Sub LoadTree()
19+
Dim tree As New JsonObject With {
20+
.Id = viewer.filepath.FileName,
21+
.JsonType = JsonType.Object,
22+
.Value = viewer.pack.superBlock
23+
}
24+
25+
Call LoadTree(tree, viewer.pack.superBlock)
26+
Call packTree.Render(New JsonObjectTree(tree))
27+
End Sub
28+
29+
Private Sub LoadTree(tree As JsonObject, group As StreamGroup)
30+
For Each dir As StreamGroup In group.dirs
31+
Dim node As New JsonObject With {
32+
.Id = dir.fileName,
33+
.JsonType = JsonType.Object,
34+
.Value = dir,
35+
.Parent = tree
36+
}
37+
38+
Call tree.Fields.Add(node)
39+
Call LoadTree(node, dir)
40+
Next
41+
42+
For Each file As StreamBlock In group.files.OfType(Of StreamBlock)
43+
Dim node As New JsonObject With {
44+
.Id = file.fileName,
45+
.JsonType = JsonType.Value,
46+
.Parent = tree,
47+
.Value = file
48+
}
49+
50+
Call tree.Fields.Add(node)
51+
Next
52+
End Sub
53+
54+
Private Sub packTree_ViewAction(node As JsonViewerTreeNode) Handles packTree.ViewAction
55+
If node.JsonObject.Value Is Nothing OrElse TypeOf node.JsonObject.Value Is StreamGroup Then
56+
Return
57+
End If
58+
59+
Dim file As StreamBlock = DirectCast(node.JsonObject.Value, StreamBlock)
60+
61+
Select Case file.fileName.ExtensionSuffix
62+
Case "json"
63+
Case "txt"
64+
Case "jpg", "png", "jpeg", "bmp", "tiff"
65+
Case "xml"
66+
Case "html"
67+
Case "csv"
68+
Case "rtf"
69+
Case Else
70+
' view in binary mode
71+
72+
End Select
73+
End Sub
374
End Class

src/viewers/HDSViewer/FormViewer.Designer.vb

Lines changed: 32 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/viewers/HDSViewer/FormViewer.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,10 @@
120120
<metadata name="MenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121121
<value>17, 17</value>
122122
</metadata>
123+
<metadata name="VisualStudioToolStripExtender1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124+
<value>132, 17</value>
125+
</metadata>
126+
<metadata name="StatusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
127+
<value>349, 17</value>
128+
</metadata>
123129
</root>
Lines changed: 13 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
Imports Galaxy.Data.JSON
2-
Imports Galaxy.Data.JSON.Models
3-
Imports Microsoft.VisualBasic.DataStorage.HDSPack.FileSystem
1+
Imports Microsoft.VisualBasic.DataStorage.HDSPack.FileSystem
2+
Imports Microsoft.VisualStudio.WinForms.Docking
43

54
Public Class FormViewer
65

7-
Dim WithEvents packTree As JsonViewer
8-
Dim pack As StreamPack
9-
Dim filepath As String
10-
11-
Private Sub FormViewer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
12-
packTree = New JsonViewer
13-
packTree.Dock = DockStyle.Fill
14-
15-
Call SplitContainer1.Panel1.Controls.Add(packTree)
16-
End Sub
6+
Friend pack As StreamPack
7+
Friend filepath As String
8+
Friend explorer As FormExplorer
179

1810
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
1911
Call Me.Close()
@@ -31,66 +23,20 @@ Public Class FormViewer
3123
filepath = file.FileName
3224
pack = StreamPack.OpenReadOnly(file.FileName)
3325
Text = $"HDS Pack Viewer [{filepath}]"
34-
35-
LoadTree()
26+
explorer.LoadTree()
27+
explorer.DockState = DockState.DockLeft
3628
End If
3729
End Using
3830
End Sub
3931

40-
Private Sub LoadTree()
41-
Dim tree As New JsonObject With {
42-
.Id = filepath.FileName,
43-
.JsonType = JsonType.Object,
44-
.Value = pack.superBlock
45-
}
32+
Private Sub DockPanel1_ActiveContentChanged(sender As Object, e As EventArgs) Handles DockPanel1.ActiveContentChanged
4633

47-
Call LoadTree(tree, pack.superBlock)
48-
Call packTree.Render(New JsonObjectTree(tree))
4934
End Sub
5035

51-
Private Sub LoadTree(tree As JsonObject, group As StreamGroup)
52-
For Each dir As StreamGroup In group.dirs
53-
Dim node As New JsonObject With {
54-
.Id = dir.fileName,
55-
.JsonType = JsonType.Object,
56-
.Value = dir,
57-
.Parent = tree
58-
}
59-
60-
Call tree.Fields.Add(node)
61-
Call LoadTree(node, dir)
62-
Next
63-
64-
For Each file As StreamBlock In group.files.OfType(Of StreamBlock)
65-
Dim node As New JsonObject With {
66-
.Id = file.fileName,
67-
.JsonType = JsonType.Value,
68-
.Parent = tree,
69-
.Value = file
70-
}
71-
72-
Call tree.Fields.Add(node)
73-
Next
74-
End Sub
75-
76-
Private Sub packTree_ViewAction(node As JsonViewerTreeNode) Handles packTree.ViewAction
77-
If node.JsonObject.Value Is Nothing OrElse TypeOf node.JsonObject.Value Is StreamGroup Then
78-
Return
79-
End If
80-
81-
Dim file As StreamBlock = DirectCast(node.JsonObject.Value, StreamBlock)
82-
83-
Select Case file.fileName.ExtensionSuffix
84-
Case "json"
85-
Case "txt"
86-
Case "jpg", "png", "jpeg", "bmp", "tiff"
87-
Case "xml"
88-
Case "html"
89-
Case "csv"
90-
Case "rtf"
91-
Case Else
92-
' view in binary mode
93-
94-
End Select
36+
Private Sub FormViewer_Load(sender As Object, e As EventArgs) Handles Me.Load
37+
explorer = New FormExplorer
38+
explorer.viewer = Me
39+
explorer.Show(DockPanel1)
40+
explorer.DockState = DockState.DockLeftAutoHide
9541
End Sub
9642
End Class

0 commit comments

Comments
 (0)