private void cancelButton_Click(object sender, RoutedEventArgs e) { NewTypeViewModel viewModel = DataContext as NewTypeViewModel; if (viewModel != null) { viewModel.CancelCommand.Execute(null); } Close(); }
public static async Task <string> NewTypeAsync(Authentication authentication, ITypeCategoryDescriptor descriptor) { var dialog = await NewTypeViewModel.CreateInstanceAsync(authentication, descriptor); if (dialog?.ShowDialog() == true) { return(dialog.TypeName); } return(null); }
private async void Restore(IDataBase dataBase) { if (this.isFirst == true) { return; } this.isFirst = true; var domainContext = dataBase.GetService(typeof(IDomainContext)) as IDomainContext; var items = await domainContext.Dispatcher.InvokeAsync(() => { var restoreList = new List <System.Action>(); var domains = domainContext.Domains.Where(item => item.DataBaseID == dataBase.ID).ToArray(); foreach (var item in domains) { if (item.Users.Contains(this.authenticator.ID) == false) { continue; } var itemPath = item.DomainInfo.ItemPath; var itemType = item.DomainInfo.ItemType; if (item.Host is ITypeTemplate template) { if (itemType == "NewTypeTemplate") { var category = dataBase.TypeContext[itemPath] as ITypeCategory; var dialog = new NewTypeViewModel(this.authenticator, category, template); restoreList.Add(new System.Action(() => dialog.ShowDialog())); } else if (itemType == "TypeTemplate") { var type = dataBase.TypeContext[itemPath] as IType; var dialog = new EditTemplateViewModel(this.authenticator, type, template); restoreList.Add(new System.Action(() => dialog.ShowDialog())); } } } return(restoreList.ToArray()); }); foreach (var item in items) { if (this.cremaAppHost.IsLoaded == false) { return; } item(); } }