Hi Walter,
I am implementing a dynamic node filter.
I have a custom PartManager that implements FilterNodeForData.
I have a button that can toggle a filter state. When button is pressed, I call PartManager.RebuildNodeElements();
This seems to work, it will filter properly. However, 99% of the time when transitioning from unfiltered to filtered, my diagram layout will go “blank” (it will show no nodes).
For debugging, I implemented the Diagram LayoutCompleted event handler. I set a breakpoint in this method, and can confirm that it is being called when a “blank” layout is drawn. If I then resize my window, the LayoutCompleted event handler gets called again, and then the diagram is no longer blank. (displays as i would expect)
It’s curious, this only occurs when I am filtering data, when I toggle back to an unfiltered state, it always draws the diagram correctly the first time.
Unfiltered --> click filter button --> RebuildNodeElements --> FilterNodeForData --> LayoutCompleted (blank). Manually resize window containing diagram --> LayoutCompleted --> (not blank)
Filtered --> click filter button --> RebuildNodeElements --> FilterNodeForData --> LayoutCompleted (not blank)
I guess my question is, is this the correct approach?
public class GoXamCustomPartManager : PartManager
{
/// <summary>
/// FilterNodeForData
/// </summary>
/// <param name="item"></param>
/// <returns>
/// False - Item will be filtered out
/// True - Item will not be filtered out
/// </returns>
protected override bool FilterNodeForData(object nodedata, Northwoods.GoXam.Model.IDiagramModel model)
{
BusinessEntityGoXamViewModel begxvm = nodedata as BusinessEntityGoXamViewModel;
if (begxvm != null)
{
bool retVal = begxvm.BusinessEntitySearch(begxvm);
return (retVal);
}
else
{
return (base.FilterNodeForData(nodedata, model));
}
}
}
....
....
....
/// <summary>
/// Filter
/// </summary>
/// <param name="item"></param>
/// <returns>
/// False - Item will be filtered out
/// True - Item will not be filtered out
/// </returns>
public virtual bool BusinessEntitySearch(object item)
{
BusinessEntityBaseViewModel bebvm = item as BusinessEntityBaseViewModel;
if (bebvm == null)
{
return (false);
}
else if (((_FilterResponder == true) && (bebvm.Data.Type == Enum_ProxySalIDType.Responder)) ||
((_FilterEquipment == true) && (bebvm.Data.Type == Enum_ProxySalIDType.Equipment))
)
{
return (false);
}
else
{
return (true);
}
}