NPalette.FromFile Type parameter example needed


Author
Message
Brad Swearingen
Brad Swearingen
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
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
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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
Brad Swearingen
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
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 (329 views, 1.00 KB)
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
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
Craig Swearingen
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
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));


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search