Jump to content
Software FX Community

How do I invoke an internal command programatically?


jmcdaniel
 Share

Recommended Posts

I have a case where I am emulating the Chart's menu items.  I am able to quite easily build them via interrogating the CommandsCollection.  What I am having a harder time doing is telling the chart "okay, now execute command BLAH".  Or rather saying "execute command BLAH for series X, point Y".

Currently I have the following code which works aside from not being able to pass series / point info. It uses internal interfaces which no doubt is not what I should be doing (or have to do).  Can anyone think of a way to do this>

 

Cheers,

Jesse

 

  Command cmd = ...   // if the item needs [un]checking, do so...   if ((cmd.Style & CommandStyles.TwoState) != CommandStyles.None)   cmd.Checked = !cmd.Checked;   ChartFX.WinForms.Internal.ICommandCollection iCommands = (ChartFX.WinForms.Internal.ICommandCollection)commands;     // invoke the chart's internal handling of this item   ChartFX.WinForms.Internal.CommandsEventArgs args =   new ChartFX.WinForms.Internal.CommandsEventArgs(   tag.m_chart, 0, tag.m_id, 0, tag.m_subId);     iCommands.OnCommandEvent(args); 

Link to comment
Share on other sites

You are using an internal interface (ChartFX.WinForms.Internal.ICommandCollection) which is not supported.

The knowledge of the context does not belong to the command but to the element that displayed it and to which the command will come back. So there is no way for you to tell a command to execute for a specific object, the paradigm is more like you tell the context object to execute a command, however none of this API is exposed.

What exactly are you looking for? Why do you need to execute an Internal Command. There is API that allows you to do the same thing the command does.

 

Link to comment
Share on other sites

 Thanks Frank,

 

I was afraid you would say that.  Simply put I am replacing all the ChartFX context menus with standard .NET 2.0 ToolStrip*.  This is needed as we wish to add our own menu items to the chart's and we do things that ChartFX menus cannot do, such as embed custom controls in menu items.  Not to mention we have a large volume of code that can be reused (we launch our menus outside of the chart also), look & feel consistency, etc.   My goal was to write functions that interogatte the chart, build a menu which is the same as the charts (whatever that is) and those items will then do whatever the chart's menu item would do, all while being 100% naive as to what that action in fact is.  Effectively you are telling me I cannot write code which is quite that generic but rather I will need a large switch statement to carry out the actions...  Certainly doable, but more of a pain.

 Cheers,

 Jesse 

Link to comment
Share on other sites

  • 9 months later...
  • 5 months later...

The problem is that the original menu still shows up. I was struggling with it, and found out that this piece of code does a good job of wiping out all right-click menus of chartfx:

foreach (Command com in chart1.Commands)

{

com.Enabled = false;

com.SubCommands.Clear();

}

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.

 Share

×
×
  • Create New...