Frank Hileman's WebLog

Vector Graphics with VG.net and Visual Studio Integration

Vote to Remove Enum.IsDefined From All System.Drawing Members

Enum.IsDefined is an expensive call taking a significant amount of time, and boxing (allocating memory) on every call. There are numerous System.Drawing property setters that call Enum.IsDefined. Officially, Enum.IsDefined is recognized by MS as a problem and now its usage violates official .NET Framework Design Guidelines.

Speed up VG.net and other graphical applications, and reduce heap usage, by voting for this relatively minor change:

Remove Enum.IsDefined calls from all System.Drawing members

Published Thursday, November 11, 2004 6:48 AM by Frank Hileman

Comments

# re: Vote to Remove Enum.IsDefined From All System.Drawing Members@ Friday, November 12, 2004 4:19 PM

Hi. Great work so far.

Have you though about wrapping the gdiplus dll, yourself. You could probably get better performance than they do, by removing any unncesseary error checking. Btw. I am in the planning stages of writing a specialized charting component. Do you think VG. Net is an option as the rendering engine for my charting component.

by Hart

# re: Vote to Remove Enum.IsDefined From All System.Drawing Members@ Friday, November 12, 2004 4:33 PM

Hi Hart,

Thanks! We did think about wrapping the GDI+ dll. You are right, we could get some perf gains that way. But then we have to use PInvoke, unsafe code, and our code would no longer run in a restricted security setting. Nor would it be portable to Mono. We are hoping to run on Mono as soon as the System.Drawing implementation is up to snuff.

Should you use VG.net for your charting component? If it is animated, you may gain some speed that way. We optimize that stuff heavily. If you are drawing a strip-chart there is a particular optimization we do not do (the scrolling of the bits) that you would have to do yourself, so for that, I would say no.

If your chart is not animated then it is just up to the ease of use of the API. If you find VG.net easier to use than GDI+, and you don't want to create your own retained mode system, go for VG.net. Of course we would do it that way, if we were to build one (we are not).

# re: Vote to Remove Enum.IsDefined From All System.Drawing Members@ Friday, November 12, 2004 7:53 PM

Hi no scrolling needed. So your component is still a strong contender. One thing I find missing in your product, is a roadmap; describing what your plans are. If the roadmap was accessable, I would thing it would be easier to justify the most expensive package (2000$).

To see what I mean take a look at: http://projects.edgewall.com/trac/roadmap

by Hart

# re: Vote to Remove Enum.IsDefined From All System.Drawing Members@ Friday, November 12, 2004 8:33 PM

Yes, I think you are right. A roadmap would be helpful. Our priorities have been change fairly frequently, depending on customer demand. We listen to all suggestions, but customers have higher priority.

Here is a rough roadmap, what we hope to accomplish short/long term. We divide the customers into two categories: standard GUI component users (buttons, sliders, 3D effects) and technical users (SCADA, simulations, various animated schematics and diagrams).

So from short to longer term, in both categories.

GUI:

- A basic 3D effects component library, so no one has to be an artist.

- Layout commands in the designer.

- Standard GUI base classes, that define standard behavior (Button, slider, menu, radio, etc).

- Stand-alone text. It is possible to do that now but we could have more properties available.

- A built in layout manager (Anchoring/docking) as well as support for custom layout managers. Additional Element events.

- Keyboard focus and a pure vector text entry box (no windows forms control).

- One or two GUI libraries based on those base classes -- a separate product. People can also build their own.

- Support for user defined Appearance "variables" -- essentially allowing the user to add custom data to Styles and objects, that can be combined using appearance inheritance just like the standard properties. For example, to define the light orientation for shadow effects.

- Effects: both digital filters and vector types of effects, as well as user defined effects.

- Shadow support in core engine.

- Ability to perform union and subtraction of paths in the designer.


Technical:

- Linear and radial gauges, as well as scale classes (for tick marks).

- Connectors: define input and output ports in custom Picture clases, as well as custom Connector classes that can dynamically determine which objects are connectable. Connectors move when the connected objects move, and record a logical relationship between objects.

- Designer Components: Grid, zoom, pan, create, move, resize, serialization, all in a simple component. Then an additional component with more advanced behavior, such as undo/redo, edit points, transformations, and appearance property editing. For people who build custom designers.

- Run-time support of "Style sheets": external files defining styles in MyXaml that can be dynamically loaded.

- The ability to define real-time data channels and bind to real-time data without writing code. Great for scada. OPC Client for that.

Well, that is only a rough outline, don't take the priorities too seriously. But you can see some of the things we are working on and considering.