public void AddCommand(string DatasetName, UAMenuCommand Command)
{
//Creating a copy of command for putting it in "History" menu
UAMenuCommand uamc = new UAMenuCommand(); // new obj needed, because same obj can't be child at two places.
uamc.commandformat = Command.commandformat;
uamc.commandoutputformat = Command.commandoutputformat;
uamc.commandtemplate = Command.commandtemplate;
uamc.commandtype = Command.commandtype;
//29Mar2013 //If History Menu text is not present. Dont add this command to "History" menu
if(Command.text == null || Command.text.Length < 1)
{ return; }
uamc.text = Command.text;//Command name shown in "History" menu
//now create menuitem for each command and add to "History" menu
DashBoardItem item = new DashBoardItem();
item.Command = new AUAnalysisCommandBase(); // should point to AUAnalysisCommandBase
item.CommandParameter = uamc;
item.isGroup = false;
item.Name = uamc.text;// MenuName
MenuItem newmi = CreateItem(item);
//Check if command already in history menu ///
bool ExistsInHistory = false;
int miIndex = 0;
foreach (MenuItem mi in commandhistmenu.Items)
{
if (mi.Header == newmi.Header)//command already in History
{
ExistsInHistory = true;
break;
}
miIndex++;
}
// Adding command with "latest executed on top" in menu ///
if (ExistsInHistory)
{
commandhistmenu.Items.RemoveAt(miIndex);
}
commandhistmenu.Items.Insert(0, newmi);//Adding to "History" menu
}