Skip to content

Commit

Permalink
[Refactoring UI Code] WIP: Inline UI Definition instead of xaml compi…
Browse files Browse the repository at this point in the history
…lation (#2629)

* try1: apps panel

* refractor

- removed Get-TabXaml.ps1
- removed compilation part from compile.ps1
- removed existing changes from main.ps1
- added Invoke-WinUtilUIElements.ps1
- refractor existing changes into new function
- modified inputXML to call function

* removed unused replacementlogics

* fix toggle style

* move naming from winutil to wpf

* hotfixes

- reworked function calling
- working on correct theming support

* hotfix

* hotfix

fix missing elements
fix var naming

* some fixes

* hotfixes

* add image logic

* fix ? issue in search

* filter out unneeded categories

* cleanup

* fix border styling

* fixes

* preprocessing

* fix typo

* last fixes & add notes

* Update functions/public/Invoke-WPFUIElements.ps1

Co-authored-by: Mr.k <mineshtine28546271@gmail.com>

* fix margin

* fix tabcontent margin

* fix some other margin issues

* move fixed values outside of iterations

* little fix

* add Dispatcher.Invoke

* add error handling for styles

* Update functions/public/Invoke-WPFUIElements.ps1

Co-authored-by: Mr.k <mineshtine28546271@gmail.com>

* remove dispatcher

* fix search

* move run & undo tweaks to be fixed

* add error handling

* fix throw exception

* fixed accidental removal of findname grid call

* add padding & margin to make search look good

* remove grid to make it look correctly on small window

* fix rectangle

* Compiler Improvements for PR #2465 (#7)

* Remove the Special Character Escaping for Json Files as there's no need for it anymore

* Simplify 'application.json' Json Prefix Addition in 'Compile.ps1' Script

Thanks to  @fam007e for improving this section in his PR #2587 changes

Co-authored-by: fam007e <faisalmoshiur@gmail.com>

---------

Co-authored-by: fam007e <faisalmoshiur@gmail.com>

* fix margin of search clear

* fix cursor on clear search button

* undo fixed run & undo

* refractor themes.json

* undo themes.json

---------

Co-authored-by: Mr.k <mineshtine28546271@gmail.com>
Co-authored-by: fam007e <faisalmoshiur@gmail.com>
Co-authored-by: Chris Titus <contact@christitus.com>
  • Loading branch information
4 people authored Aug 28, 2024
1 parent 322d527 commit c741e00
Show file tree
Hide file tree
Showing 5 changed files with 401 additions and 327 deletions.
41 changes: 2 additions & 39 deletions Compile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,14 @@ Get-ChildItem "$workingdir\functions" -Recurse -File | ForEach-Object {
}
Update-Progress "Adding: Config *.json" 40
Get-ChildItem "$workingdir\config" | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object {

$json = (Get-Content $psitem.FullName).replace("'","''")

# Replace every XML Special Character so it'll render correctly in final build
# Only do so if json files has content to be displayed (for example the applications, tweaks, features json files)
# Make an Array List containing every name at first level of Json File
$jsonAsObject = $json | convertfrom-json
$firstLevelJsonList = [System.Collections.ArrayList]::new()
$jsonAsObject.PSObject.Properties.Name | ForEach-Object {$null = $firstLevelJsonList.Add($_)}
# Note:
# Avoid using HTML Entity Codes, for example '&rdquo;' (stands for "Right Double Quotation Mark"),
# Use **HTML decimal/hex codes instead**, as using HTML Entity Codes will result in XML parse Error when running the compiled script.
for ($i = 0; $i -lt $firstLevelJsonList.Count; $i += 1) {
$firstLevelName = $firstLevelJsonList[$i]
if ($jsonAsObject.$firstLevelName.content -ne $null) {
$jsonAsObject.$firstLevelName.content = $jsonAsObject.$firstLevelName.content.replace('&','&#38;').replace('','&#8220;').replace('','&#8221;').replace("'",'&#39;').replace('<','&#60;').replace('>','&#62;').replace('','&#8212;')
$jsonAsObject.$firstLevelName.content = $jsonAsObject.$firstLevelName.content.replace('&#39;&#39;',"&#39;") # resolves the Double Apostrophe caused by the first replace function in the main loop
}
if ($jsonAsObject.$firstLevelName.description -ne $null) {
$jsonAsObject.$firstLevelName.description = $jsonAsObject.$firstLevelName.description.replace('&','&#38;').replace('','&#8220;').replace('','&#8221;').replace("'",'&#39;').replace('<','&#60;').replace('>','&#62;').replace('','&#8212;')
$jsonAsObject.$firstLevelName.description = $jsonAsObject.$firstLevelName.description.replace('&#39;&#39;',"&#39;") # resolves the Double Apostrophe caused by the first replace function in the main loop
}
}
$jsonAsObject = $json | convertfrom-json

# Add 'WPFInstall' as a prefix to every entry-name in 'applications.json' file
if ($psitem.Name -eq "applications.json") {
for ($i = 0; $i -lt $firstLevelJsonList.Count; $i += 1) {
$appEntryName = $firstLevelJsonList[$i]
foreach ($appEntryName in $jsonAsObject.PSObject.Properties.Name) {
$appEntryContent = $jsonAsObject.$appEntryName
# Remove the entire app entry, so we could add it later with a different name
$jsonAsObject.PSObject.Properties.Remove($appEntryName)
# Add the app entry, but with a different name (WPFInstall + The App Entry Name)
$jsonAsObject | Add-Member -MemberType NoteProperty -Name "WPFInstall$appEntryName" -Value $appEntryContent
}
}
Expand All @@ -110,20 +86,7 @@ Get-ChildItem "$workingdir\config" | Where-Object {$psitem.extension -eq ".json"

$xaml = (Get-Content "$workingdir\xaml\inputXML.xaml").replace("'","''")

# Dot-source the Get-TabXaml function
. "$workingdir\functions\private\Get-TabXaml.ps1"

Update-Progress "Building: Xaml " 75
$appXamlContent = Get-TabXaml "applications" 5
$tweaksXamlContent = Get-TabXaml "tweaks"
$featuresXamlContent = Get-TabXaml "feature"


Update-Progress "Adding: Xaml " 90
# Replace the placeholder in $inputXML with the content of inputApp.xaml
$xaml = $xaml -replace "{{InstallPanel_applications}}", $appXamlContent
$xaml = $xaml -replace "{{InstallPanel_tweaks}}", $tweaksXamlContent
$xaml = $xaml -replace "{{InstallPanel_features}}", $featuresXamlContent

$script_content.Add($(Write-output "`$inputXML = '$xaml'"))

Expand Down
221 changes: 0 additions & 221 deletions functions/private/Get-TabXaml.ps1

This file was deleted.

Loading

0 comments on commit c741e00

Please sign in to comment.