Jump to content
Software FX Community

Custom command on annotation context menu


Pete

Recommended Posts

I'm having trouble catching the UserCommand event from the annotations context menu.  I can add custom items to the chart context items and catch those events just fine, but I'm having trouble here. 

And by the way, it is somewhat bizarre that the default fill color for annotations is transparent, but there is no way for the end user to change the color back to transparent from their selected fill color.

ChartFX.WebForms.Annotation.Annotations annots = new ChartFX.WebForms.Annotation.Annotations();

annots.EnableUI =

true;annots.ToolBar.Visible = true;

annots.EnableViewState =

true;annots.Chart = this.chart;

annots.ToolBar.Dock = ChartFX.WebForms.

DockArea.Right;this.chart.Extensions.Add(annots);

 

// Annotation Context MenuSubCommandCollection subcommands = annots.Commands[(int)ChartFX.WebForms.Annotation.AnnCommandID.Object].SubCommands;

Command command = new Command(10);command.Style = CommandStyles.None;

command.ImageIndex = 3;

command.Text = "Set Transparent";

annots.Commands.Add(command);

subcommands.Add(command.ID);

 

-------- Javascript handler.  Is there a different handler I should be using?

<

script type="text/javascript" for="<%= this.ChartID %>" event="UserCommand(sender,eventargs)">

<!--

alert('UserCommand');

-->

Link to comment
Share on other sites

  • 1 month later...

I'm finally getting back to this.  On the javascript side, I would need the unique id of the annotations object, but I'm missing something here...

 Chart javascript:

 <script type="text/javascript" for="<%= this.ChartID %>" event="UserCommand(sender,eventargs)">

 Annotation javascript:

<script type="text/javascript" for="<%= this.AnnotationID %>" event="UserCommand(sender,eventargs)">

Unfortunately, the UniqueID of the annotations object is null.  ChartFX.WebForms.Annotation.Annotations annots = (ChartFX.WebForms.Annotation.Annotations)this.chart.Extensions[0];

return (annots != null) ? annots.UniqueID : null;

What am I missing?

Link to comment
Share on other sites

  • 2 weeks later...

The problem is that the annotation object is not part of the DOM.

I'm not sure if you can attach an event to a COM (.NET) object from JavaScript (through code).

You can get a pointer to the annotation extension from javascript by doing: 

var annotation = chart.Extensions.FindByName("Annotations");

But all the attempts I have made tried to attach an event to it have failed (I tried attachEvent, assigning the event itself).

Link to comment
Share on other sites

Well, this was one attempt at skinning the metaphorical cat.  The real problem is getting annotations back to the server side so they can be saved along with our custom representation of the chart.  Your suggestion got me part of the way there.  If I draw an object and then kick off a javascript function, I can get to the annotations and further drill down to the individual objects.  However, some of the properties don't appear javascript-friendly...

For instance, annotation.List.Item(0).Color results in "Operation not supported. Unknown error: 0x80131509"

annotation.List.Item(0).ObjectBounds is coming in as a User-Defined Type, so I can't access any of its properties.  I can get Top, Left, Height, Width from the object itself, but if the object is an arrow, I'd need ObjectBounds to get at the orientation of the arrow.

I'm still open to different implementation suggestions.  If ChartFX can't send the annotations that are drawn by the user back to the server in an SFX_SendUserCallback call, then if I could pull out the interesting properties in javascript, stuff them into XML and send them back across, I'd be okay with that too.  But I'm kind of stuck here.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...