Book a Demo

Author Topic: How to draw diamond shape in C#  (Read 7066 times)

phamrt1

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
How to draw diamond shape in C#
« on: October 01, 2008, 02:24:02 am »
How do I draw/create a diamond shape in C#?  The intent is to simulate a decision box as in a flow chart. Some code exampel will be helpful. Thanks.
phamrt1

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How to draw diamond shape in C#
« Reply #1 on: October 01, 2008, 08:21:13 am »
Diamonds are available as Decision elements and MergeNode elements.

You can also define a shape script like

Code: [Select]
shape main
{
  startpath(); // Start to trace out a path
  moveto(50,0);
  lineto(0,50);
  lineto(50,100);
  lineto(100,50);
  endpath(); // End tracing out a path
  // Fill the traced path with the fill color
  fillandstrokepath();
}

I can't give you an example of creating an element, and adding it to the diagram, but a quick look at the documentation or the code samples in the EA install directory should be enough.
« Last Edit: October 01, 2008, 08:22:14 am by simonm »

phamrt1

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: How to draw diamond shape in C#
« Reply #2 on: October 02, 2008, 03:56:12 am »

Thanks for the info. However, this leads to a more basic question:  I see those shape examples in the Tutorial but can't relate them to the code in C#.  How do I get to those shape drawing functions (starpath, lineto...) in C#? I tried accessing them through elements, diagram objects, sterotypes... but could't find them.  Can you give me a more explicit example based on an existing c# context?  I know how to create elements and add them as diagram objects to a diagram.
Thanks

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to draw diamond shape in C#
« Reply #3 on: October 02, 2008, 08:42:03 am »
There are no such primitives in the API. The shape script language is internal to EA.

However, take a look at the MDG Technologies section. Perhaps defining a custom profile with shape scripts assigned to stereotypes would solve your problem. Your c# (or whatever) add-in could then create such elements and the shapes would be applied.

Or you could simply stereotype your elements through your add-in and set up shape scripts via the usual methods. The downside here is that the settings for stereotypes and shapes are reference data. You would have to incorporate this in your projects outside of your add-in. At present there is no way to manipulate, export or import reference data via the API.

David
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How to draw diamond shape in C#
« Reply #4 on: October 03, 2008, 08:18:22 am »
Quote
The downside here is that the settings for stereotypes and shapes are reference data. You would have to incorporate this in your projects outside of your add-in. At present there is no way to manipulate, export or import reference data via the API.
Actually, provide the profile, including the shape scripts via an MDG technology given to EA in the EA_OnInitializeTechnologies event.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to draw diamond shape in C#
« Reply #5 on: October 03, 2008, 09:05:33 pm »
Simon is correct, assuming you are using an MDG Technology.

I was referring to the case where you just use a shape script, without an MDG Technology. Then you're stuck with manual transfer of reference data.

If you can tolerate the overhead of creating and distributing an MDG Technology then that's the way to go.

David
No, you can't have it!