Profile Picture

NPalette.FromFile Type parameter example needed

Posted By Brad Swearingen 12 Years Ago
Author
Message
Brad Swearingen
Posted 12 Years Ago
View Quick Profile
Forum Guru

Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 53, Visits: 3

I'm trying to provide custom palette support.  I'm on the 11.12.14.12 build.

The signature for NPalette.FromFile is this:

public static NPalette FromFile(    string filePath,   Type type)

Parameters

filePath
The fully qualified path to the specified file.
type
The type of the NPalette object requesting the load.

but the sample code you provide is this:

//copy this palette to another button
this.nButton2.Palette.Copy(NPalette.FromFile(@"C:\myPalette.xml");

This won't compile because its missing the "type" parameter.  (Its missing a right paren too.  )

How does one specify the "type" parameter?  I didn't find the "type" parameter definition helpful.  I tried typeof(NPalette) and that compiles but the call is failing for me.



Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 11 hours ago
Posts: 3,054, Visits: 3,967
Hi Brad,

Thanks for notice this error in the documentation. We will fix it for the next release.

As a type parameter you should provide a typeof(NPalette) as you did.
The failing call may be caused because of a bad structure of the custom palette xml file.

Did you create your custom palette by calling NPalette.Save or SaveToFile method?

Best Regards,
Nevron Support Team



Brad Swearingen
Posted 12 Years Ago
View Quick Profile
Forum Guru

Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)Forum Guru (53 reputation)

Group: Forum Members
Last Active: 8 Years Ago
Posts: 53, Visits: 3

Thanks for clarifying.  I first tried saving a palette through the "Save" button on the palette dialog launched via NUIManager.Palette.ShowEditor().  That produces the same .XML file that a call to NUIManager.Palette.SaveToFile produces.  Both seem like valid palette files to me and look the same.  I've attached the file I see.

If I make calls like below the FromFile always returns null for me.  I'm running on Windows7 using build 11.12.14.12.

NUIManager.Palette.SaveToFile(@"C:\temp\temppal2.xml");

NPalette pal = NPalette.FromFile(@"C:\temp\temppal2.xml", typeof(NPalette));



Attachments
temppal2.xml (296 views, 1.00 KB)
Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 11 hours ago
Posts: 3,054, Visits: 3,967
Hi Brad,

In the version you have, when you save a palette in the xml file it creates tag named NUIPalette. The correct tag should be NPalette.
This problem is fixed in the current version.

You can rename this tag after save manually or you can get the latest version where this is fixed.
Please, excuse us for the inconvenience.




Best Regards,
Nevron Support Team



Craig Swearingen
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)Supreme Being (97 reputation)

Group: Forum Members
Last Active: 7 Years Ago
Posts: 99, Visits: 654

Changing the tags from NUIPalette to NPalette in the .XML file did not work but changing the typeof to NUIPalette like below did.  Thanks.  Let me know if there is any problem with this:

NPalette pal = NPalette.FromFile(@"C:\temp\temppal2.xml", typeof(NUIPalette));





Similar Topics


Reading This Topic