@@ -68,7 +68,7 @@ private void btnCreatePackages_Click(object sender, EventArgs e)
68
68
var outputPath = txtOutputPath . Text ;
69
69
70
70
var erroredIds = new List < string > ( ) ;
71
- string currentPackage = string . Empty ;
71
+ ExtensionInfo currentPackage = null ;
72
72
73
73
try
74
74
{
@@ -80,22 +80,22 @@ private void btnCreatePackages_Click(object sender, EventArgs e)
80
80
// create plugin packages
81
81
foreach ( var sel in lstPlugins . SelectedItems )
82
82
{
83
- currentPackage = ( string ) sel ;
84
- var fi = creator . CreatePluginPackage ( ( string ) sel ) ;
85
- if ( ! LogMessage ( fi , ( string ) sel ) )
83
+ currentPackage = ( ExtensionInfo ) sel ;
84
+ var fi = creator . CreatePluginPackage ( currentPackage . Path ) ;
85
+ if ( ! LogMessage ( fi , currentPackage . Name ) )
86
86
{
87
- erroredIds . Add ( currentPackage ) ;
87
+ erroredIds . Add ( currentPackage . Path ) ;
88
88
}
89
89
}
90
90
91
91
// create theme packages
92
92
foreach ( var sel in lstThemes . SelectedItems )
93
93
{
94
- currentPackage = ( string ) sel ;
95
- var fi = creator . CreateThemePackage ( ( string ) sel ) ;
96
- if ( ! LogMessage ( fi , ( string ) sel ) )
94
+ currentPackage = ( ExtensionInfo ) sel ;
95
+ var fi = creator . CreateThemePackage ( currentPackage . Path ) ;
96
+ if ( ! LogMessage ( fi , currentPackage . Name ) )
97
97
{
98
- erroredIds . Add ( currentPackage ) ;
98
+ erroredIds . Add ( currentPackage . Name ) ;
99
99
}
100
100
}
101
101
@@ -151,61 +151,89 @@ private void btnReadDescriptions_Click(object sender, EventArgs e)
151
151
152
152
btnReadDescriptions . Enabled = false ;
153
153
154
- ReadPlugins ( vpp ) ;
155
- ReadThemes ( vpp ) ;
154
+ ReadPackages ( vpp ) ;
156
155
157
156
btnReadDescriptions . Enabled = true ;
158
157
}
159
158
160
- private void ReadPlugins ( IVirtualPathProvider vpp )
159
+
160
+ private void ReadPackages ( IVirtualPathProvider vpp )
161
161
{
162
162
if ( ! ValidatePaths ( ) )
163
163
return ;
164
164
165
+ lstPlugins . DisplayMember = "Name" ;
166
+ lstPlugins . ValueMember = "Path" ;
167
+ lstThemes . DisplayMember = "Name" ;
168
+ lstThemes . ValueMember = "Path" ;
169
+
165
170
lstPlugins . Items . Clear ( ) ;
166
- foreach ( var dir in vpp . ListDirectories ( "~/Plugins" ) )
167
- {
168
- var filePath = vpp . Combine ( dir , "Description.txt" ) ;
169
- if ( ! vpp . FileExists ( filePath ) )
170
- continue ;
171
+ lstThemes . Items . Clear ( ) ;
171
172
172
- try
173
+ IEnumerable < string > dirs = Enumerable . Empty < string > ( ) ;
174
+
175
+ if ( vpp . DirectoryExists ( "~/Plugins" ) || vpp . DirectoryExists ( "~/Themes" ) )
176
+ {
177
+ if ( vpp . DirectoryExists ( "~/Plugins" ) )
173
178
{
174
- var descriptor = PluginFileParser . ParsePluginDescriptionFile ( vpp . MapPath ( filePath ) ) ;
175
- if ( descriptor != null )
176
- {
177
- lstPlugins . Items . Add ( descriptor . FolderName ) ;
178
- }
179
+ dirs = dirs . Concat ( vpp . ListDirectories ( "~/Plugins" ) ) ;
179
180
}
180
- catch
181
+ if ( vpp . DirectoryExists ( "~/Themes" ) )
181
182
{
182
- continue ;
183
+ dirs = dirs . Concat ( vpp . ListDirectories ( "~/Themes" ) ) ;
183
184
}
184
185
}
185
- }
186
-
187
- private void ReadThemes ( IVirtualPathProvider vpp )
188
- {
189
- if ( ! ValidatePaths ( ) )
190
- return ;
186
+ else
187
+ {
188
+ dirs = vpp . ListDirectories ( "~/" ) ;
189
+ }
191
190
192
- lstThemes . Items . Clear ( ) ;
193
- foreach ( var dir in vpp . ListDirectories ( "~/Themes" ) )
191
+ foreach ( var dir in dirs )
194
192
{
195
- var filePath = vpp . Combine ( dir , "theme.config" ) ;
193
+ bool isTheme = false ;
194
+
195
+ // is it a plugin?
196
+ var filePath = vpp . Combine ( dir , "Description.txt" ) ;
196
197
if ( ! vpp . FileExists ( filePath ) )
197
- continue ;
198
+ {
199
+ // ...no! is it a theme?
200
+ filePath = vpp . Combine ( dir , "theme.config" ) ;
201
+ if ( ! vpp . FileExists ( filePath ) )
202
+ continue ;
203
+
204
+ isTheme = true ;
205
+ }
198
206
199
207
try
200
208
{
201
- var manifest = ThemeManifest . Create ( vpp . MapPath ( dir ) ) ;
202
- lstThemes . Items . Add ( manifest . ThemeName ) ;
209
+ if ( isTheme )
210
+ {
211
+ var manifest = ThemeManifest . Create ( vpp . MapPath ( dir ) ) ;
212
+ lstThemes . Items . Add ( new ExtensionInfo ( dir , manifest . ThemeName ) ) ;
213
+ }
214
+ else
215
+ {
216
+ var descriptor = PluginFileParser . ParsePluginDescriptionFile ( vpp . MapPath ( filePath ) ) ;
217
+ if ( descriptor != null )
218
+ {
219
+ lstPlugins . Items . Add ( new ExtensionInfo ( dir , descriptor . FolderName ) ) ;
220
+ }
221
+ }
203
222
}
204
223
catch
205
224
{
206
225
continue ;
207
226
}
208
227
}
228
+
229
+ if ( lstPlugins . Items . Count > 0 )
230
+ {
231
+ tabMain . SelectedIndex = 0 ;
232
+ }
233
+ else if ( lstThemes . Items . Count > 0 )
234
+ {
235
+ tabMain . SelectedIndex = 1 ;
236
+ }
209
237
}
210
238
211
239
private bool ValidatePaths ( )
@@ -217,13 +245,6 @@ private bool ValidatePaths()
217
245
return false ;
218
246
}
219
247
220
- //if (!Directory.Exists(txtOutputPath.Text))
221
- //{
222
- // MessageBox.Show("Output path does not exist! Please specify an existing path", "Path error", MessageBoxButtons.OK, MessageBoxIcon.Error);
223
- // txtOutputPath.Focus();
224
- // return false;
225
- //}
226
-
227
248
return true ;
228
249
}
229
250
0 commit comments