I am developing a search agent plugin that contains two custom controls, one with DisplayMode SnapToParentWidth and another InDialog,
When selecting a search category, the “CreateSearchFilterEditControl” method will create a new object for each custom “SearchFilterEditControl” control.
When the filter category is selected and the popup window is closed,
SearchFilterEditControl → Close() method is not invoked for controls having "DisplayMode " set toInDoalog, and for controls having "DisplayMode " set to SnapToParentWidth, the Close() method is invoked every time.
This is causing an increase in memory when a Search Filter popup window gets opened that is calling the “CreateSearchFilterEditControl” method to create a new object.
I have tried with the sample provided in “mipsdk-samples-plugin” → “SCSearchAgent” it is also behaving the same.
Code chunk from “mipsdk-samples-plugin” → “SCSearchAgent” Sample
Close Method is not Invoked
public partial class SCAnimalsSearchAreaFilterEditHostControl : SearchFilterEditControl
{
public SCAnimalsSearchAreaFilterEditHostControl()
{
InitializeComponent();
}
public override void Init()
{
base.Init();
_legacyControl.FilterValue = FilterValue as StringFilterValue;
}
// This method is not Invoked
public override void Close()
{
base.Close();
}
}
Close Method is Invoked
public partial class SCAnimalsSearchFilterEditControl : SearchFilterEditControl, INotifyPropertyChanged
{
//......
//......
public override void Init()
{
SelectedIndex = FindIndexOfSpeciesName(((StringFilterValue)FilterValue).Text);
FilterValue.Changed += FilterValue_Changed;
}
// Close Method is Invoked Everytime
public override void Close()
{
FilterValue.Changed -= FilterValue_Changed;
}
public SCAnimalsSearchFilterEditControl()
{
InitializeComponent();
DataContext = this;
}
private void FilterValue_Changed(object sender, EventArgs e)
{
SelectedIndex = FindIndexOfSpeciesName(((StringFilterValue)FilterValue).Text);
}
private int FindIndexOfSpeciesName(string name)
{
var av = (StringFilterValue)FilterValue;
Species species = Species.First(x => x.Name == av.Text);
return Species.IndexOf(species);
}
}
