1- using Microsoft . UI . Xaml . Controls ;
1+ using ABI . System ;
2+ using Microsoft . UI . Xaml ;
3+ using Microsoft . UI . Xaml . Controls ;
4+ using Microsoft . UI . Xaml . Media ;
5+ using Microsoft . VisualBasic ;
26using System ;
37using System . Collections . Generic ;
8+ using System . ComponentModel ;
49using System . Linq ;
10+ using System . Net . WebSockets ;
511using System . Text ;
612using System . Threading . Tasks ;
13+ using Windows . ApplicationModel ;
714using Windows . Graphics . Printing . PrintSupport ;
15+ using Windows . UI . Text ;
16+ using WingetUIWidgetProvider ;
17+ using static System . Net . Mime . MediaTypeNames ;
818
919namespace WingetUIWidgetProvider
1020{
@@ -207,20 +217,15 @@ private static string GeneratePackageStructure(int index)
207217 ""cells"": [
208218 {
209219 ""type"": ""TableCell"",
210- ""minHeight"": ""2px"",
211220 ""items"": [
212221 {
213222 ""type"": ""Image"",
214- ""url"": ""${Icon" + index . ToString ( ) + @"}"",
215- ""horizontalAlignment"": ""Center"",
216- ""width"": ""24px"",
217- ""spacing"": ""Padding""
223+ ""url"": ""${Icon" + index . ToString ( ) + @"}""
218224 }
219225 ],
220- ""backgroundImage"": {
221- ""verticalAlignment"": ""Center""
222- },
223- ""verticalContentAlignment"": ""Center""
226+ ""verticalContentAlignment"": ""Center"",
227+ ""minHeight"": ""36px"",
228+ ""spacing"": ""None""
224229 },
225230 {
226231 ""type"": ""TableCell"",
@@ -252,7 +257,8 @@ private static string GeneratePackageStructure(int index)
252257 ]
253258 }
254259 ],
255- ""verticalContentAlignment"": ""Center""
260+ ""verticalContentAlignment"": ""Center"",
261+ ""spacing"": ""None""
256262 },
257263 {
258264 ""type"": ""TableCell"",
@@ -265,17 +271,22 @@ private static string GeneratePackageStructure(int index)
265271 ""title"": ""🡇"",
266272 ""verb"": """ + Verbs . UpdatePackage + index . ToString ( ) + @""",
267273 ""data"": {},
268- ""tooltip"": ""Update this package""
274+ ""tooltip"": ""Update this package"",
275+ ""spacing"": ""None""
269276 }
270277 ],
271- ""horizontalAlignment"": ""Center""
278+ ""horizontalAlignment"": ""Center"",
279+ ""spacing"": ""None""
272280 }
273281 ],
274282 ""verticalContentAlignment"": ""Center"",
275- ""minHeight"": ""36px""
283+ ""spacing"": ""None"",
284+ ""minHeight"": ""36px"",
285+ ""spacing"": ""None""
276286 }
277287 ],
278- ""$when"": ""${$root.Package" + index . ToString ( ) + @"Visisble}""
288+ ""$when"": ""${$root.Package" + index . ToString ( ) + @"Visisble}"",
289+ ""spacing"": ""None""
279290 }" ;
280291 return package ;
281292 }
@@ -313,6 +324,92 @@ public static string GetData_UpdatesList(int count, Package[] upgradablePackages
313324 return data ;
314325 }
315326
327+ private static string GetUpdatesListTemplate ( int numOfPackages )
328+ {
329+ string basestr = @"
330+ {
331+ ""type"": ""Container"",
332+ ""items"": [
333+ {
334+ ""type"": ""TextBlock"",
335+ ""text"": ""Available Updates: ${count}"",
336+ ""wrap"": true,
337+ ""weight"": ""bolder"",
338+ ""size"": ""medium""
339+ },
340+ {
341+ ""type"": ""Table"",
342+ ""columns"": [
343+ {
344+ ""width"": ""32px""
345+ },
346+ {
347+ ""width"": 1
348+ },
349+ {
350+ ""width"": ""42px""
351+ }
352+ ],
353+ ""rows"": [" ;
354+
355+ for ( int i = 0 ; i < numOfPackages ; i ++ )
356+ basestr += GeneratePackageStructure ( i ) + ( ( i + 1 == numOfPackages ) ? "\n " : ",\n " ) ;
357+
358+ basestr += @"],
359+ ""spacing"": ""None"",
360+ ""showGridLines"": false,
361+ ""height"": ""stretch"",
362+ ""verticalCellContentAlignment"": ""Top""
363+ },
364+ {
365+ ""type"": ""Container"",
366+ ""verticalContentAlignment"": ""Center"",
367+ ""items"": [
368+ {
369+ ""type"": ""TextBlock"",
370+ ""text"": ""${upgradablePackages}"",
371+ ""horizontalAlignment"": ""Center"",
372+ ""spacing"": ""None"",
373+ ""weight"": ""Lighter"",
374+ ""isSubtle"": true
375+ }
376+ ],
377+ ""height"": ""stretch"",
378+ ""spacing"": ""None""
379+ },
380+ {
381+ ""type"": ""ActionSet"",
382+ ""actions"": [
383+ {
384+ ""type"": ""Action.Execute"",
385+ ""title"": ""Update all"",
386+ ""verb"": """ + Verbs . UpdateAll + @"""
387+ },
388+ {
389+ ""type"": ""Action.Execute"",
390+ ""title"": ""Reload"",
391+ ""verb"": """ + Verbs . Reload + @"""
392+ },
393+ {
394+ ""type"": ""Action.Execute"",
395+ ""title"": ""WingetUI"",
396+ ""verb"": """ + Verbs . ViewUpdatesOnWingetUI + @"""
397+ }
398+ ],
399+ ""id"": ""buttons"",
400+ ""horizontalAlignment"": ""Center"",
401+ ""spacing"": ""None""
402+ }
403+ ],
404+ ""height"": ""stretch"",
405+ ""$when"": ""${$root.UpdatesList}"",
406+ ""spacing"": ""None"",
407+ ""verticalContentAlignment"": ""Center""
408+ }" ;
409+
410+ return basestr ;
411+ }
412+
316413 private static string UpdatesList = @"
317414 {
318415 ""type"": ""Container"",
@@ -529,13 +626,15 @@ public static string GetData_UpdatesInCourse()
529626 }
530627 }" ;
531628
532- public static string UpdatesTemplate = @"
629+ public static string GetUpdatesTemplate ( int numOfUpdates )
630+ {
631+ return @"
533632 {
534633 ""type"": ""AdaptiveCard"",
535634 ""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"",
536635 ""version"": ""1.5"",
537636 ""body"": [
538- " + UpdatesList + @"
637+ " + GetUpdatesListTemplate ( numOfUpdates ) + @"
539638 ],
540639 ""rtl"": false,
541640 ""refresh"": {
@@ -545,7 +644,6 @@ public static string GetData_UpdatesInCourse()
545644 }
546645 }
547646 }" ;
548-
549-
647+ }
550648 }
551649}
0 commit comments