Not getting drop down from design time validation error icon in rehosted designer  
Author Message
Blipwort





PostPosted: Windows Workflow Foundation, Not getting drop down from design time validation error icon in rehosted designer Top

I am not getting the drop down from the validation error icon in a rehosted designer.

I have set

WorkflowTheme.CurrentTheme.AmbientTheme.ShowConfigErrors = true;

in the WorkflowDesignerControl() constructor, so I get the icon but not the error message etc.

Is there another step




Software Development for Windows Vista19  
 
 
Jon Flanders





PostPosted: Windows Workflow Foundation, Not getting drop down from design time validation error icon in rehosted designer Top

Yes - first you need to provide a MenuCommandService.

Then you need some special handling code in the ShowContextMenu override - here is an example:

public override void ShowContextMenu(CommandID menuID, int x, int y)

{

ICollection coll = this.GetCommandList(menuID.Guid);

if (menuID == WorkflowMenuCommands.DesignerActionsMenu)

{

MenuCommand last = GetLast(coll);//Needed because of code in unmanaged part of VS.NET

string err = last.Properties["Text"].ToString();

ContextMenuStrip cms = new ContextMenuStrip();

ToolStripMenuItem mi = new ToolStripMenuItem(err, null, new EventHandler(this.OnMenuClicked));

cms.Items.Add(mi);

mi.Tag = last;

last.Invoke();

WorkflowView view1 = base.GetService(typeof(WorkflowView)) as WorkflowView;

if (view1 != null)

{

EventHandler d = null;

d = delegate(object o, EventArgs e)

{

cms.MouseLeave -= d;

cms.Close();

};

cms.MouseLeave += d;

cms.Show(view1, view1.PointToClient(new Point(x, y)));

}}

}

There are two other methods then you need - one is the OnMenuClicked (which is very much boilerplate code):

private void OnMenuClicked(object sender, EventArgs e)

{

MenuItem item1 = sender as MenuItem;

if ((item1 != null) && (item1.Tag is MenuCommand))

{

MenuCommand command1 = item1.Tag as MenuCommand;

command1.Invoke();

}

}

And then I have this method called GetLast:

MenuCommand GetLast(ICollection coll)

{

IEnumerator e = coll.GetEnumerator();

MenuCommand last = null;

while (e.MoveNext())

{

last = e.Current as MenuCommand;

}

return last;

}

You need this method because unlike all of the other command - this CommandID isn't found with FindCommand.