private async void SelectedCategoryAction(object param) { if (param == null) { return; } var cate = param as CAKE_TYPE; var clonedCate = cate.ShallowClone(); this._categoryDialogViewModel = new CategoryDialogViewModel() { SelectedCakeType = clonedCate, Status = "Edit cake type" }; var view = new CategoryDialogControl { DataContext = this._categoryDialogViewModel }; //show the dialog var result = await DialogHost.Show(view, MainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, EditCateDialogClosingEventHandler); //check the result... Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.uri = new Uri("http://www.rheagroup.com"); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); this.serviceLocator = new Mock <IServiceLocator>(); this.navigation = new Mock <IThingDialogNavigationService>(); ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object); this.serviceLocator.Setup(x => x.GetInstance <IThingDialogNavigationService>()).Returns(this.navigation.Object); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.session = new Mock <ISession>(); var person = new Person(Guid.NewGuid(), this.cache, this.uri) { Container = this.siteDir }; this.session.Setup(x => x.ActivePerson).Returns(person); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.siteDir.Person.Add(person); var rdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { Name = "testRDL", ShortName = "test" }; this.category = new Category(Guid.NewGuid(), this.cache, this.uri) { Name = "category", ShortName = "cat" }; var cat1 = new Category(Guid.NewGuid(), this.cache, this.uri) { Name = "category1", ShortName = "cat1" }; rdl.DefinedCategory.Add(cat1); this.siteDir.SiteReferenceDataLibrary.Add(rdl); var transactionContext = TransactionContextResolver.ResolveContext(this.siteDir); this.transaction = new ThingTransaction(transactionContext, null); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(this.siteDir.SiteReferenceDataLibrary)); this.cache.TryAdd(new CacheKey(rdl.Iid, null), new Lazy <Thing>(() => rdl)); var dal = new Mock <IDal>(); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); this.viewmodel = new CategoryDialogViewModel(this.category, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, null, null); }
private async Task GetUserInputAsync() { var categoryDialog = new CategoryDialog(); var dialogViewModel = new CategoryDialogViewModel(async instance => { await dialogCoordinator.HideMetroDialogAsync(this, categoryDialog); if (!instance.Cancel) { ProcessUserInput(instance.Category); } }); categoryDialog.DataContext = dialogViewModel; await dialogCoordinator.ShowMetroDialogAsync(this, categoryDialog); }
private async void ExecuteAddCateDialog(object obj) { this._categoryDialogViewModel = new CategoryDialogViewModel() { SelectedCakeType = new CAKE_TYPE(), Status = "Add cake type" }; var view = new CategoryDialogControl { DataContext = this._categoryDialogViewModel }; //show the dialog var result = await DialogHost.Show(view, MainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, AddCateDialogClosingEventHandler); //check the result... Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }
public void VerifyThatSuperCategoriesAreCorrectlyPopulated() { var sRdl10 = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); var cat10 = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "10" }; var cat11 = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "11" }; sRdl10.DefinedCategory.Add(cat10); sRdl10.DefinedCategory.Add(cat11); var sRdl20 = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); sRdl20.RequiredRdl = sRdl10; var cat20 = new Category(Guid.NewGuid(), this.cache, null) { ShortName = "20" }; var cat21 = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "21" }; sRdl20.DefinedCategory.Add(cat20); sRdl20.DefinedCategory.Add(cat21); var mRdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); mRdl.RequiredRdl = sRdl20; var cat30 = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "30" }; var cat32 = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "32" }; var cat31 = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "31" }; var cat311 = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "311" }; var cat3111 = new Category(Guid.NewGuid(), null, this.uri) { ShortName = "3111" }; var cat312 = new Category(Guid.NewGuid(), this.cache, this.uri) { ShortName = "312" }; mRdl.DefinedCategory.Add(cat30); mRdl.DefinedCategory.Add(cat31); mRdl.DefinedCategory.Add(cat32); mRdl.DefinedCategory.Add(cat311); mRdl.DefinedCategory.Add(cat3111); mRdl.DefinedCategory.Add(cat312); cat3111.SuperCategory.Add(cat311); cat3111.SuperCategory.Add(cat312); cat311.SuperCategory.Add(cat31); cat312.SuperCategory.Add(cat31); cat31.SuperCategory.Add(cat20); cat20.SuperCategory.Add(cat10); var sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); sitedir.SiteReferenceDataLibrary.Add(sRdl10); sitedir.SiteReferenceDataLibrary.Add(sRdl20); var model = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); model.RequiredRdl.Add(mRdl); sitedir.Model.Add(model); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(sitedir); this.session.Setup(x => x.OpenReferenceDataLibraries).Returns(new HashSet <ReferenceDataLibrary>(sitedir.SiteReferenceDataLibrary) { mRdl }); var vm = new CategoryDialogViewModel(cat3111, this.transaction, this.session.Object, true, ThingDialogKind.Create, null, null, null); var container = vm.PossibleContainer.SingleOrDefault(x => x.Iid == mRdl.Iid); vm.Container = container; Assert.AreEqual(9, vm.PossibleSuperCategories.Count); this.cache.TryAdd(new CacheKey(mRdl.Iid, null), new Lazy <Thing>(() => mRdl)); this.cache.TryAdd(new CacheKey(cat31.Iid, null), new Lazy <Thing>(() => cat31)); var clonerdl = mRdl.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(sitedir); this.transaction = new ThingTransaction(transactionContext, clonerdl); vm = new CategoryDialogViewModel(cat31.Clone(false), this.transaction, this.session.Object, true, ThingDialogKind.Update, null, clonerdl); Assert.AreEqual(10, vm.PossibleSuperCategories.Count); }
public CategoryDialog(CategoryDialogViewModel viewModel) { _viewModel = viewModel; InitializeComponent(); }