in Tools/Apps/Microsoft.PowerApps.Tools.AppChangeFinder/ChangeFinderViewModel.cs [195:289]
public async void BrowseBtnClicked(object obj)
{
var uiContext = SynchronizationContext.Current;
await Task.Run(async () =>
{
string message = "";
var ofd = new Win32.OpenFileDialog() { Filter = "PowerApps Files (*.msapp)|*.msapp" };
var result = ofd.ShowDialog();
if (result == false) return;
PathTxtBox = ofd.FileName;
try
{
if (string.IsNullOrWhiteSpace(PathTxtBox) ||
Path.GetExtension(PathTxtBox) != ".msapp")
{
message = "Select the PowerApps App!";
}
else
{
this.IsLoading = true;
ChangeManager changeManager = new ChangeManager();
searchResult = changeManager.GetModifiedControleList(PathTxtBox);
if (searchResult == null || searchResult.Count == 0
|| (searchResult.Count == 1 && searchResult[0].ControlList.Count == 0))
{
var screenName = $"No change found in the App!";
searchResult = new List<ModifiedResult>
{
new ModifiedResult
{
ScreenName = screenName
}
};
}
//Clear the binded object everytime
ScreenList = new ObservableCollection<DataModel>();
//DataModel local variables
DataModel _dataModel = null;
Controls _controls = null;
Property _property = null;
//Fill the object by traversing
searchResult.ForEach(r =>
{
_dataModel = new DataModel();
_dataModel.ScreenName = r.ScreenName;
r.ControlList?.ForEach(s =>
{
_controls = new Controls();
_controls.ControlName = $"{s.ControlName}";
//_property = new Property();
//_property.PropertyName = $"Parent: {s.Parent}";
//_controls.Properties.Add(_property);
s.Script?.ForEach(q =>
{
if (!string.Equals(q.DefaultSetting, q.InvariantScript,
StringComparison.OrdinalIgnoreCase))
{
_property = new Property();
_property.PropertyName = q.Property;
_property.Properties.Add(new PropertyDetails()
{ IsBaseLine = true, Name = "", Value = q.DefaultSetting });
_property.Properties.Add(new PropertyDetails()
{ IsBaseLine = false, Name = "", Value = q.InvariantScript });
_controls.Properties.Add(_property);
}
});
_dataModel.Controls.Add(_controls);
});
uiContext.Send(x => ScreenList.Add(_dataModel), null);
});
//Clone to local list
OrginalScreenList = ScreenList;
this.IsLoading = false;
}
}
catch (Exception ex)
{
message = ex.Message;
}
if (!string.IsNullOrWhiteSpace(message))
{
MessageBoxButton button = MessageBoxButton.OK;
System.Windows.MessageBox.Show(message, "Message", button);
}
});
}