Replied On January 18, 2004 03:11 PM UTC
Thank you for the positive feedback about the product. I''ll try to answer your questions here and I''ll put register an incident to add a sample and more documentation to explain this part of the product.
Adding images to a symbol can be done in the Symbol Designer. Look on the Drawing toolbar for the Insert Image button. You can add either bitmaps or metafiles to the symbol. Metafiles are a better choice if you intend to allow the user to scale the symbol. By the way, I did re-test this feature and I didn''t have any problems with it. You mentioned that the current version of the product didn''t support doing this. If you had problems getting it to work, I''d like to get more information from you so that I can reproduce the problem.
Once you have created a symbol palette, you can either use it with the PaletteGroupBar control or you can load it directly into a SymbolPalette object. The PaletteGroupBar control implements a drag and drop interface for adding symbols to diagrams. If you load the symbol palette directly into a SymbolPalette object, you can create symbols from it and add them to diagram any way you like (such as with the InsertSymbolTool).
Creating symbols using a SymbolPalette requires a bit of explanation. A SymbolPalette is really just a type of Diagram model that contains SymbolModel objects. You can access the SymbolModel objects in the SymbolPalette using ICompositeNode interface it implements. In other words, the SymbolPalette class has methods such as GetChild() and GetChildByName() that will return you the SymbolModel you want. You''ll have to downcast the object returned to a SymbolModel. Once you have a SymbolModel object, you just call its CreateSymbol() method to create an instance of the symbol it represents.
You can also add images to a symbol programmatically. The code would look something like this.
Symbol mySymbol = new Symbol();
BitmapNode symbolBmp = new BitmapNode("mysymbol.bmp");
It sounds like you want to sub-class the Symbol class in order to support images. It''s fine to do that, but unless you have other app-specific functionality to add to the sub-class it really isn''t necessary. As I''ve already explained, the product supports adding images to symbols out of the box. If you want to see an example of sub-class the Symbol class, take a look at the DynamicSymbol sample.
Once you have a Symbol in the diagram, you can access it programmatically to set properties. It sounds like you want to show and hide images in the symbol based on events and state information in your application. This can be done very easily. If you build the symbol with the Symbol Designer, just add all of the images you want to the Symbol and set the Visible property to false for the images that are hidden by default. Then add code to handle the events that trigger changes in appearance and set the Visible property on the images that need to be hidden and shown. This is actually a good reason to subclass the Symbol class, because you can encapsulate the code to show and hide the images.
By the way, you can subclass the Symbol and still use the Symbol Designer to layout the symbol. The PlugInAssembly and PlugInClass properties on the SymbolModel can be set to point to your subclass.
If you need to find a particular symbol in the diagram, use the ICompositeNode interface implemented by the model. For example, you can call Model.GetChildByName("SymbolName") to get a reference to a symbol with a particular name.
I hope this helps. Please let me know if you need any more tips.
>After spending few very interesting moments with Diagram, I firmly decided that I like it a lot. It seems to be a great mix: almost trivial to use as a set of building blocks -- the enclosed Diagram Builder sample is a great example of that. It offers almost the same functionality like say ILOG''s JViews Workflow package, which also contains a Diagram Builder in source form, which is at least 10 times more complex.
>On the other side, your product offers as detailed API as anyone could ever need - and that duality (simple and sophisticated) is the freat mix I suggested above.
>My real intent with this message is to ask for a tip. I am not sure that I will make the necessary leap without having more examples, so here is my question: can you illustrate the API based approach to constructing a symbol, which is based on an image (rather than a composition of the supported elementary figures, which implement the required Inode (and other) interface?
>More specifically: I could easily figure out how to make a an "Image Symbol", with the Symbol Designer application (and by the way, I know that that would not even work with the current release). What I would rather do, is to create the symbol with C# code instead. Then I would really have a "live object" in my (workflow) application, where I can animate a view of my workflow for example.
>Lastly, I am not sure that I understand how could use the Symbol Designer to create a symbol, add all kinds of attributes to it, and access them from my c# code. I believe that I saw a brief discussion on late time binding on the Diagram UG - but all that seems pretty incomplete, and lacks samples.
>Can you help me with any of these questions, please?