Home Forums General XMetaL Discussion Is it possible to update CSS programmatically in C#? Reply To: Is it possible to update CSS programmatically in C#?

Derek Read

Reply to: Is it possible to update CSS programmatically in C#?

There are currently three strategies for modifying CSS that I can think of. Which you use will depend on your needs:

1. Swap the currently loaded CSS file on disk with your modified version (how this is done with any particular language will vary but the easiest way is to have both files in the same folder with different names and then simply rename them so that the CSS file you wish to use matches yourDTDname.css) then call the API Document_object.RefreshCssStyle(). Note that this method will cause the entire document to be reformatted, causing the user's selection to be lost (you may use various strategies to handle that, including inserting a temporary PI to remember the current position, then moving the selection after the API call, then removing the PI at the end).

2. Use new APIs available in the 6.0 releases. See my post here: http://forums.xmetal.com/index.php/topic,594.msg1911.html#msg1911
This is similar to #1 except that it avoids the need to swap files on disk.

3. Set the property Selection.ContainerStyle for a particular node. This will affect one node only (this is different from using a CSS selector that may match one or more nodes in a document, and remains in effect only as long as the document remains open in Tags On or Normal views).

Reply

Products
Downloads
Support