public FeedbackFlyoutVM()
{
RefreshCommand = new RelayCommand(() =>
{
this.IsBusy = true;
var tasks = FeedbackThreadList.Where(t => !t.FeedbackThread.IsNewThread)
.Select(t => FeedbackManager.Current.RefreshFeedbackThreadVMAsync(SelectedFeedbackThread));
Task.WaitAll(tasks.ToArray(),20);
this.IsBusy = false;
});
AddThreadCommand = new RelayCommand(() =>
{
var threadVM = new FeedbackThreadVM();
this.FeedbackThreadList.Add(threadVM);
FeedbackManager.Current.AddFeedbackThread(threadVM);
this.SelectedFeedbackThread = threadVM;
});
CloseThreadCommand = new RelayCommand(async () =>
{
var msg = this.SelectedFeedbackThread.IsNewThread ?
LocalizedStrings.LocalizedResources.CloseNewThreadQuestion
: LocalizedStrings.LocalizedResources.CloseActiveThreadQuestion;
var dialog = new MessageDialog(msg);
dialog.Commands.Add(new UICommand() { Id = true, Label = LocalizedStrings.LocalizedResources.Yes });
dialog.Commands.Add(new UICommand() { Id = false, Label = LocalizedStrings.LocalizedResources.No });
var result = await dialog.ShowAsync();
FeedbackFlyoutVM.ShowFlyout();
if ((bool)result.Id)
{
if (this.SelectedFeedbackThread.IsNewThread) { FeedbackManager.Current.SaveFeedbackThreadTokens(); }
this.FeedbackThreadList.Remove(this.SelectedFeedbackThread);
if (!this.FeedbackThreadList.Any())
{
this.FeedbackThreadList.Add(new FeedbackThreadVM());
}
this.SelectedFeedbackThread = this.FeedbackThreadList.First();
}
});
}