in Tools/Apps/Microsoft.PowerApps.Tools.AppChangeFinder/ChangeFinderViewModel.cs [295:390]
public void SearchBtnClicked(object obj)
{
string searchTxt = SearchTextBox;
if (!string.IsNullOrEmpty(searchTxt))
{
Task.Factory.StartNew(() =>
{
this.IsLoading = true;
ObservableCollection<DataModel> searchedScreenList = new ObservableCollection<DataModel>();
//Traverse through the object
foreach (DataModel dm in OrginalScreenList)
{
var foundScreen = new DataModel
{
ScreenName = dm.ScreenName,
Controls = new List<Controls>()
};
//Start searching with root node - screen name
if (dm.ScreenName.IndexOf(searchTxt, StringComparison.OrdinalIgnoreCase) >= 0)
{
searchedScreenList.Add(dm);
break;
}
//Searching in child node
foreach (Controls control in dm.Controls)
{
var foundControl = new Controls
{
ControlName = control.ControlName
};
if (control.ControlName.IndexOf(searchTxt, StringComparison.OrdinalIgnoreCase) >= 0)
{
foundScreen.Controls = new List<Controls> { foundControl };
searchedScreenList.Add(foundScreen);
break;
}
foreach (Property prop in control.Properties)
{
var foundProp = new Property
{
Properties = prop.Properties,
PropertyName = prop.PropertyName
};
if (!string.IsNullOrEmpty(prop.PropertyName) && prop.PropertyName.IndexOf(searchTxt, StringComparison.OrdinalIgnoreCase) >= 0)
{
foundControl.Properties = new List<Property> { foundProp };
foundScreen.Controls = new List<Controls> {foundControl};
searchedScreenList.Add(foundScreen);
break;
}
foreach (PropertyDetails propDetails in prop.Properties)
{
var foundPropDetails = new PropertyDetails
{
Name = propDetails.Name,
Value = propDetails.Value
};
if (!string.IsNullOrEmpty(propDetails.Name) && propDetails.Name.IndexOf(searchTxt, StringComparison.OrdinalIgnoreCase) >= 0)
{
foundProp.Properties = new List<PropertyDetails> {foundPropDetails};
foundControl.Properties = new List<Property> { foundProp };
foundScreen.Controls = new List<Controls> { foundControl };
searchedScreenList.Add(foundScreen);
break;
}
if (!string.IsNullOrEmpty(propDetails.Value) && propDetails.Value.IndexOf(searchTxt, StringComparison.OrdinalIgnoreCase) >= 0)
{
foundProp.Properties = new List<PropertyDetails> { foundPropDetails };
foundControl.Properties = new List<Property> { foundProp };
foundScreen.Controls = new List<Controls> { foundControl };
searchedScreenList.Add(foundScreen);
break;
}
}
}
}
}
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
////Set property or change UI compomponents.
this.IsLoading = false;
ScreenList = searchedScreenList;
});
});
}
else
{
ScreenList = OrginalScreenList;
}
this.IsLoading = false;
}