Need example of IStream usage with SaveSettings...

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Need example of IStream usage with SaveSettings...

Post by DSSavant »

OK, I admit it, I'm not the sharpest nail in the batch ;-)

Could I get a C# example on making calls to SaveSettings and LoadSettings using Streams? And as a bonus, could I get an example that shows _just_ saving the tool characteristics as compared to all settings?

I would like to save my user's "Set as default properties" for each tool (Pencil, Note, etc.) but not the position of the Panes or ...

Pseudo code:

Code: Select all

// Saving settings
Create stream?
_viewer.DoVerb("Tools", "SaveSettings", ?????, ?????);

// Loading settings
MemoryStream mstream = GetMySettingsFromSomePlace();
IStream istream = MemoryStreamToIStream(); ??????

_viewer.DoVerb(null, "LoadSettings", istream, ?????);
Obviously, the stuff above is wrong. What I'm missing is how to get the IStream compliant stream hooked in. Any help would be appreciated.

Also, the documentation indicates I can save the settings to an INI file. The current manifestation saves to a PDF. Is an INI even possible (not that I want to do that but ...)?

Thanks for the help.
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2352
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Need example of IStream usage with SaveSettings...

Post by Vasyl-Tracker Dev Team »

Hi, DSSavant.
What I'm missing is how to get the IStream compliant stream hooked in. Any help would be appreciated.
Please check the C#-examples folder in our Viewer ActiveX. Take a look at the OpenDocumentFromStream/SaveDocumentToStream examples.
There you will see the special Stream-To-IStream Helper (IStreamWrapper).
And as a bonus, could I get an example that shows _just_ saving the tool characteristics as compared to all settings?
I would like to save my user's "Set as default properties" for each tool (Pencil, Note, etc.) but not the position of the Panes or ...
Sorry, no simple way for this, currently the settings-data is not documented. I could suggest you the following solution:
1. collect info about current tool-styles:

Code: Select all

    ...    
    // rect 
    int curStyleID = 0;
    GetProperty("Tools.Rect.Style", out curStyle);
    string curStyle = "Commenting.Rect.Styles[#" + curStyle "].";
    int fillColor = 0; // COLORREF
    GetProperty(curStyle + "FColor", out fillColor);
    ...
    // pencil
    ...
2. use LoadSettings to load ALL new settings and collect again new tool-styles.
3. compare these compilations as you wanted...
Also, the documentation indicates I can save the settings to an INI file. The current manifestation saves to a PDF. Is an INI even possible (not that I want to do that but ...)?
Currently we save settings in PDF-format only. In the new version (V3) we've implemented a special programming-interface to read/write settings data directly, and you will be able to support your own format of settings data.

HTH.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
DSSavant
User
Posts: 216
Joined: Thu Jul 08, 2004 7:29 pm

Re: Need example of IStream usage with SaveSettings...

Post by DSSavant »

Thanks Vasyl, I did look at the sample code but was doing something wrong along the way. Having said that, I think I will go with the individual style method as I see that allowing me to "port" my user's settings to version 3 when it releases without issue. Further, I will not have to deal with all of the other settings I do not want to save.

Thanks again.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Need example of IStream usage with SaveSettings...

Post by Tracker Supp-Stefan »

Glad we could help DSSavant!

Cheers,
Stefan
Post Reply