60001732 Ability to load commands menu and resources from stream

Article 60001732
Type Wish
Product Engine
Version 6025
Date Added 6/14/2012 12:00:00 AM
Fixed (6/13/2013 12:00:00 AM)
Submitted by Janne Carlson

Summary

Is it possible to load a commands.txt not from a file on disk but from a stream ?

Solution

In version 6026 we added 3 methods that will allow you to load menu.txt , commands.txt and vdres.txt from System.IO.StreamReader stream.
We added two methods at the vdFramedControl like below

summary> Loads the specified menu to the control.
param name="file">A System.IO.StreamReader stream to load the menu from. This can be a text file in the resources of the project as the menu.txt that we provide.
param name="ImagesPath">The directory where the Images are for the icons of the menu.
public void LoadMenu(System.IO.StreamReader file, string ImagesPath)

summary>Load all commands from an existing System.IO.StreamReader stream.
param name="file">The System.IO.StreamReader stream to load the commands from. This can be a project's resources file that is common to the commands.txt that we provide.
returns>True if the commands were succesfully loaded.
public bool LoadCommands(System.IO.StreamReader file)

And also to the vdSerialize.dll we added the following method
summary> Initialize the globalization dictionary with the specified StreamReader stream containing all globalized strings.
param name="stream">A System.IO.StreamReader stream that contains a all strings.Note the strings are separeted with the character "^".
public GlobalizedDictionary(StreamReader stream)//6026_60001732

The following example shows how you can load commands , menu and vdres from a project's resources that we added the previous files at the resources of the project

//Load Menu From Resources
MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream);
writer.Write(Resources.Menu);
writer.Flush();
stream.Position = 0;
StreamReader Menu = new StreamReader(stream);
vdFramedControl1.LoadMenu (Menu,"C:\\vdraw6\\REDIS\\AnyCPU\\images");

//Load Commands From Resources
stream = new MemoryStream();
writer = new StreamWriter(stream);
writer.Write(Resources.Commands);
writer.Flush();
stream.Position = 0;
StreamReader Commands = new StreamReader(stream);
vdFramedControl1.LoadCommands(Commands);

//Load vdRes From Resources
stream = new MemoryStream();
writer = new StreamWriter(stream);
writer.Write(Resources.vdres);
writer.Flush();
stream.Position = 0;
StreamReader vdRes = new StreamReader(stream);
VectorDraw.Serialize.GlobalizedDictionary.Dictionary = new VectorDraw.Serialize.GlobalizedDictionary(vdRes);

Send comments on this topic.