Nevron .NET Vision Documentation
Persistency

Overview
Nevron Command Bars provide an easy and consistent way to persist their state in a binary format. The NCommandBarsState is a stand-alone object which, given a valid NCommandBarsManager instance, can serialize its state into a memory or file stream. You can control the level of the serialization process by using the PersistencyFlags enumeration which specifies which parts of the framework should be serialized.
Saving State

The following code demonstrates how to persist an existing NCommandBarsManager state:

C#
Copy Code
//create a command bars state object
NCommandBarsState state = new NCommandBarsState();
//assign it a valid manager to work onto.
state.Manager = this.nCommandBarsManager;
//specify custom persistency flags - exclude image lists from serialization
state.PersistencyFlags &= ~NCommandBarsState.Flags.ImageLists;

//call the parameterless overload of the Save method
//as it will automatically display a dialog box to choose file name
state.Save();
Visual Basic
Copy Code
'create a command bars state object
Dim state As NCommandBarsState = New NCommandBarsState()
'assign it a valid manager to work onto.
state.Manager = Me.nCommandBarsManager
'specify custom persistency flags - exclude image lists from serialization
state.PersistencyFlags ^= Not NCommandBarsState.Flags.ImageLists

'call the parameterless overload of the Save method
'as it will automatically display a dialog box to choose file name
state.Save()
You should register all image lists used by the framework with the ImageLists collection of the NCommandBarsManager.
Loading State

The following code demonstrates how to load an existing command bars state:

C#
Copy Code
//create a NCommandBarsState object
NCommandBarsState state = new NCommandBarsState();
state.Manager = this.nCommandBarsManager1;

state.Load("c:\\myState.cbs");
Visual Basic
Copy Code
'create a NCommandBarsState object
Dim state As NCommandBarsState = New NCommandBarsState()
state.Manager = Me.nCommandBarsManager1

state.Load("c:\\myState.cbs")
Reading/Writing Into a Stream

The NCommandBarsState object provides yet another useful feature - it supports direct read/write into a stream.

 

The following code demonstrates how to use read/write to stream methods:

C#
Copy Code
//create a NCommandBarsState object
NCommandBarsState state = new NCommandBarsState();
state.Manager = this.nCommandBarsManager1;

//create a memory stream object
MemoryStream stream = new MemoryStream();
//save current state to the stream
state.Write(stream);

//you may load the same state to another manager
state.Manager = this.nCommandBarsManager2;
state.Read(stream);
See Also

 

 


©2017. Nevron Software LLC.

Send Feedback