Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Recursive updating of custom palette XML files #79

Open
PWagner1 opened this issue Jul 3, 2024 · 32 comments
Open

[Feature Request]: Recursive updating of custom palette XML files #79

PWagner1 opened this issue Jul 3, 2024 · 32 comments

Comments

@PWagner1
Copy link
Contributor

PWagner1 commented Jul 3, 2024

As per discussion Krypton-Suite/Standard-Toolkit#1552 (comment)

@giduac
Copy link

giduac commented Jul 3, 2024

There are some themes in there that carry a version number in the file name.
How would that be handled if, let's say, the version for all files should be set to N while some files have a different number in their file name.

Updating all xml files in a directory structure with a certain number can be done.

image

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

There are some themes in there that carry a version number in the file name. How would that be handled if, let's say, the version for all files should be set to N while some files have a different number in their file name.

Updating all xml files in a directory structure with a certain number can be done.

image

Hi @giduac

Need to strip all (or delete) files of _vX so that there is a 'base' version of the file, then within the code logic create a directory named vX, then place all the 'upgraded' files within that directory.

Hope this makes sense :)

@giduac
Copy link

giduac commented Jul 3, 2024

Can you please write that out more explicit and complete including the various conditions so we have a clear description of what should happen under which circumstances?

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

Can you please write that out more explicit and complete including the various conditions so we have a clear description of what should happen under which circumstances?

Hi @giduac

Yes sure

  1. Remove or rename any files that have _v# in them, to create a 'base' version of the palette
  2. Create or update the existing 'Palette Upgrade Tool' UI to accept folders as a input/output (possibly use list boxes, so that the user can see the contents of the directory)
  3. Update the existing 'Upgrade' button code to utilise the KryptonCustomPaletteBase upgrade features (possibly use a foreach loop here?)
  4. For the output directory use the default name as the current palette version. This is already defined in the TKs GlobalStaticValues, so use this as it'll make it easier to support in the future
  5. Possibly allow the folder to launch the new folder in explorer once 'upgrading' is complete

@giduac
Copy link

giduac commented Jul 3, 2024

Some more questions please.

  • Be more specific per item.
  • To come to a full functional description which completely takes out the guess work.

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

Some more questions please.

  • Be more specific per item.
  • To come to a full functional description which completely takes out the guess work.

Hi @giduac

I think I've got it... let me know if you want to see the full code...

// Validate output path to check if it exists
            ValidateOutputPath(ktxtOutputDirectory.Text);

            // Loop through the file array
            foreach (var paletteFile in GetPaletteFiles(ktxtInputDirectory.Text))
            {
                // Upgrade the file and store it into the newly created directory
                kcpbUpgrader.ImportWithUpgrade(File.OpenRead(Path.GetFullPath(paletteFile)));

                // Export the file
                kcpbUpgrader.Export(File.OpenWrite($"{ktxtOutputDirectory}\\{paletteFile}.xml"), false);
            }

cc. @Smurf-IV

@giduac
Copy link

giduac commented Jul 3, 2024

Yeah sure, push the branch...

PWagner1 added a commit that referenced this issue Jul 3, 2024
@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

@giduac It's still very much alpha software

image

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

So, the logic works, but we hit a snag here...

image

Any ideas @Smurf-IV?

PWagner1 added a commit that referenced this issue Jul 3, 2024
@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

Hi @Smurf-IV & @giduac

Just a thought... should we just have one schema, so it doesn't go boom?

@giduac
Copy link

giduac commented Jul 3, 2024

So, the logic works, but we hit a snag here...

image

Any ideas @Smurf-IV?

with which file does that happen?
Is that file sound?

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

So, the logic works, but we hit a snag here...
image
Any ideas @Smurf-IV?

with which file does that happen? Is that file sound?

@giduac

On the xml files, try building it & testing it for yourself

@giduac
Copy link

giduac commented Jul 3, 2024

You've added an icon to the program that's outside of the repo...

Does it happen with a specific file?

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 3, 2024

You've added an icon to the program that's outside of the repo...

Does it happen with a specific file?

MS has broken the resource feature (again)... this is what happens

PUTBug

@giduac
Copy link

giduac commented Jul 3, 2024

Cannot build:
image

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 4, 2024

Cannot build: image

Why did MS have to break the resource editor? Will fix later today.

@Smurf-IV
Copy link
Member

Smurf-IV commented Jul 4, 2024

Any ideas @Smurf-IV?

Not enough information in the picture to give an appropriate answer

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 4, 2024

Hi @giduac

Please retry again using fixes implemented today

@giduac
Copy link

giduac commented Jul 4, 2024

image

@giduac
Copy link

giduac commented Jul 5, 2024

There are a couple of problems in the program which you didn't see when writing the code.
Forget the "Bells and Whistles" for now and focus on the context.

A good description and design saves you time and greatly improves quality. This usually delivers better solutions than pulling it from the sleeve on the go!

So BACK to the drawing board, BEFORE you continue writing more code.

Your previous preliminary list of what the program should accomplish.

  1. Remove or rename any files that have _v# in them, to create a 'base' version of the palette
  2. Create or update the existing 'Palette Upgrade Tool' UI to accept folders as a input/output (possibly use list boxes, so that the user can see the contents of the directory)
  3. Update the existing 'Upgrade' button code to utilize the KryptonCustomPaletteBase upgrade features (possibly use a foreach loop here?)
  4. For the output directory use the default name as the current palette version. This is already defined in the TKs GlobalStaticValues, so use this as it'll make it easier to support in the future
  5. Possibly allow the folder to launch the new folder in explorer once 'upgrading' is complete

Again the questions to:

  • Describe per item what should happen and how. If you think the list is incomplete, add to it.
  • Describe what should NOT happen (and why).
  • Describe checks that will make sure you are handling the right input.
  • Describe checks that will make sure you are outputting the correct information.
  • Take out all the guess work and make it concrete.
  • Come to a full functional description.

A plan doesn't have to be written up from the go but can also grow and improved upon....

When you have completed this, reevaluate the code and make a plan to change the code to fall inline with your functional description.

Post your findings here when you are done, if you like, and we'll discuss them....

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 5, 2024

Hi @giduac

To answer the last reply, I think the code in the ST should be reset back to using 1 schema, rather than having 2. See https://github.com/Krypton-Suite/Standard-Toolkit/blob/811a1f683d0be639e962132ba8548e574642defc/Source/Krypton%20Components/Krypton.Toolkit/Controls%20Toolkit/KryptonCustomPaletteBase.cs

As for error/version checking, KryptonCustomPaletteBase should already be able to handle these, as part of that PR. The aim was not to have this as a per application basis, and to have it part of the ST.

The new UI design should act as a 'visual' wrapper to use these APIs and to allow bulk upgrading. The current design only allows a user to upgrade 1 file at a time.

Linked FR: Krypton-Suite/Standard-Toolkit#1050

@giduac
Copy link

giduac commented Jul 5, 2024

@Wagnerp
The plan will give you all the answers, you now trying to scrape together.
Don't let that plan scare you off. The more you do it the better you get.

Please complete the previous and make a good plan.

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 5, 2024

@giduac

First thing first is to 'rollback' KryptonCustomPaletteBase to using 1 schema, this should be a v90 task. as it was somewhat stable in v8x. I'll do this today.

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 6, 2024

Hi @Smurf-IV & @giduac

I've narrowed it down to {"Illegal characters in path."}, but the stack trace does not give anything obvious. Not sure if it does not like spaces?

@giduac
Copy link

giduac commented Jul 6, 2024

@Wagnerp
Run it outside of VS as a debug build and produce the error there ... (CTRL+F5)
Investigate the error messages

@giduac
Copy link

giduac commented Jul 6, 2024

@Wagnerp Run it outside of VS as a debug build and produce the error there ... (CTRL+F5) Investigate the error messages

@Wagnerp
What are did you find out?

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 6, 2024

@Wagnerp Run it outside of VS as a debug build and produce the error there ... (CTRL+F5) Investigate the error messages

@Wagnerp What are did you find out?

@giduac

image

Stacktrace:

************** Exception Text **************
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.Path.GetFileName(String path)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamReader..ctor(String path)
at Krypton.Toolkit.KryptonCustomPaletteBase.PerformUpgrade(Stream stream) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controls Toolkit\KryptonCustomPaletteBase.cs:line 2256
at Krypton.Toolkit.KryptonCustomPaletteBase.ImportWithUpgrade(Stream stream) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controls Toolkit\KryptonCustomPaletteBase.cs:line 2241
at PaletteUpgradeTool.PaletteUpgradeTool.UpgradePalettes(String inputPath, String outputPath) in D:\Development\Krypton\Theme-Palettes\Applications\Source\Palette Upgrade Tool\Palette Upgrade Tool\UI\PaletteUpgradeTool.cs:line 136
at PaletteUpgradeTool.PaletteUpgradeTool.kbtnUpgrade_Click(Object sender, EventArgs e) in D:\Development\Krypton\Theme-Palettes\Applications\Source\Palette Upgrade Tool\Palette Upgrade Tool\UI\PaletteUpgradeTool.cs:line 86
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Krypton.Toolkit.KryptonButton.OnClick(EventArgs e) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controls Toolkit\KryptonButton.cs:line 636
at Krypton.Toolkit.KryptonButton.OnButtonClick(Object sender, MouseEventArgs e) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controls Toolkit\KryptonButton.cs:line 900
at Krypton.Toolkit.ButtonController.OnClick(MouseEventArgs e) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controller\ButtonController.cs:line 895
at Krypton.Toolkit.ButtonController.MouseUp(Control c, Point pt, MouseButtons button) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controller\ButtonController.cs:line 413
at Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\View Base\ViewBase.cs:line 562
at Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\View Base\ViewBase.cs:line 567
at Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\View Base\ViewBase.cs:line 567
at Krypton.Toolkit.ViewBase.MouseUp(Point pt, MouseButtons button) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\View Base\ViewBase.cs:line 567
at Krypton.Toolkit.ViewManager.MouseUp(MouseEventArgs e, Point rawPt) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\View Base\ViewManager.cs:line 514
at Krypton.Toolkit.VisualControlBase.OnMouseUp(MouseEventArgs e) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controls Visuals\VisualControlBase.cs:line 937
at Krypton.Toolkit.KryptonButton.OnMouseUp(MouseEventArgs e) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controls Toolkit\KryptonButton.cs:line 822
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at Krypton.Toolkit.VisualControlBase.WndProc(Message& m) in D:\Development\Krypton\Standard-Toolkit\Source\Krypton Components\Krypton.Toolkit\Controls Visuals\VisualControlBase.cs:line 1149
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9241.0 built by: NET481REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll

Palette Upgrade Tool
Assembly Version: 5.500.606.0
Win32 Version: 5.500.606.0
CodeBase: file:///D:/Development/Krypton/Theme-Palettes/Applications/Source/Palette%20Upgrade%20Tool/Palette%20Upgrade%20Tool/bin/Debug/net481/Palette%20Upgrade%20Tool.exe

System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9181.0 built by: NET481REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9236.0 built by: NET481REL1LAST_B
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9032.0 built by: NET481REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

Krypton.Toolkit
Assembly Version: 90.24.7.188
Win32 Version: 90.24.07.188
CodeBase: file:///D:/Development/Krypton/Theme-Palettes/Applications/Source/Palette%20Upgrade%20Tool/Palette%20Upgrade%20Tool/bin/Debug/net481/Krypton.Toolkit.DLL

System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9032.0 built by: NET481REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9241.0 built by: NET481REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.8.9032.0 built by: NET481REL1
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

@giduac
Copy link

giduac commented Jul 6, 2024

Why does the code fail there.....

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 6, 2024

Why does the code fail there.....

That, I don't know yet

@PWagner1
Copy link
Contributor Author

PWagner1 commented Jul 6, 2024

Is it because I'm using \ rather than \\?

  ktxtOutputDirectory.Text = $@"{Path.GetFullPath(dialog.SelectedPath)}\Palette Version {GlobalStaticValues.CURRENT_SUPPORTED_PALETTE_VERSION}\";

@giduac
Copy link

giduac commented Jul 6, 2024

If you want know more about strings and how special characters are handled read up on:

  • raw strings
  • interpolated strings
  • verbatim strings

What does your plan tell you about where the output should be written to.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants