diff --git a/Aurora/Design/Views/BaseViewModel.cs b/Aurora/Design/Views/BaseViewModel.cs index 50f8500..d7183b5 100644 --- a/Aurora/Design/Views/BaseViewModel.cs +++ b/Aurora/Design/Views/BaseViewModel.cs @@ -56,7 +56,9 @@ namespace Aurora.Design.Views /// public GetIsPlayingDelegate IsPlaying { get; set; } - public ShowModalDelegate ShowModal { get; set; } + public ShowModalDelegate ShowModal { get; set; } + + public HideModalDelegate HideModal { get; set; } #endregion Player diff --git a/Aurora/Design/Views/MainView/MainView.xaml.cs b/Aurora/Design/Views/MainView/MainView.xaml.cs index b25e5e7..5e8129c 100644 --- a/Aurora/Design/Views/MainView/MainView.xaml.cs +++ b/Aurora/Design/Views/MainView/MainView.xaml.cs @@ -28,7 +28,9 @@ namespace Aurora.Design.Views.Main /// public delegate Task SetPlayerDelegate(BaseMedia media, PlayAction action); public delegate bool GetIsPlayingDelegate(); - public delegate Task ShowModalDelegate(Type view, Type viewModel); + public delegate void ShowModalDelegate(Type view, BaseDialogViewModel viewModel); + + public delegate void HideModalDelegate(); public delegate void FinishDialogDelegate(); [XamlCompilation(XamlCompilationOptions.Compile)] @@ -175,7 +177,8 @@ namespace Aurora.Design.Views.Main { return _playerService.PlaybackState == PlaybackState.Playing; }; - vm.ShowModal = this.ShowModal; + vm.ShowModal = this.ShowModal; + vm.HideModal = this.HideModal; } @@ -234,40 +237,29 @@ namespace Aurora.Design.Views.Main } - private Task ShowModal(Type view, Type viewModel) + private void ShowModal(Type view, BaseDialogViewModel viewModel) { - return Task.Run(() => - { - object returnObj = null; + ContentPresenter modalContainer = (ContentPresenter)Modal.FindByName("ViewContent"); + var vw = (View)Activator.CreateInstance(view); - ContentPresenter modalContainer = (ContentPresenter)Modal.FindByName("ViewContent"); - var vw = (View)Activator.CreateInstance(view); - BaseDialogViewModel vm = (BaseDialogViewModel)Activator.CreateInstance(viewModel); + vw.BindingContext = viewModel; - vw.BindingContext = vm; + //Set modal container content + modalContainer.Content = vw; - //Set modal container content - modalContainer.Content = vw; + //Set visibility + ChangeModalVisiblity(true); + } - //Set visibility - ChangeModalVisiblity(true); - - AutoResetEvent autoResetEvent = new AutoResetEvent(false); - //Finish is executed by modal - vm.Finish = () => - { - ChangeModalVisiblity(false); - returnObj = vm.ReturnObject; - autoResetEvent.Set(); - }; - autoResetEvent.WaitOne(); - return returnObj; - }); + private void HideModal() + { + ChangeModalVisiblity(false); } private void ChangeModalVisiblity(bool isVisible) { Modal.IsVisible = isVisible; + Content.IsVisible = !isVisible; } } } \ No newline at end of file diff --git a/Aurora/Design/Views/Party/PartyViewModel.cs b/Aurora/Design/Views/Party/PartyViewModel.cs index 71155f1..0b5fba2 100644 --- a/Aurora/Design/Views/Party/PartyViewModel.cs +++ b/Aurora/Design/Views/Party/PartyViewModel.cs @@ -127,10 +127,12 @@ namespace Aurora.Design.Views.Party else { //Open host selection modal - var modalResult = await this.ShowModal(typeof(NewPartyDialog.NewPartyDialog), typeof(NewPartyDialogViewModel)); - if (modalResult is ConnectionDetails) + NewPartyDialogViewModel vm = new NewPartyDialogViewModel(); + ConnectionDetails details = new ConnectionDetails(); + vm.Finish = () => { - ConnectionDetails details = modalResult as ConnectionDetails; + this.HideModal(); + details = vm.ReturnObject as ConnectionDetails; _hostname = details.HostName; switch (details.ConnectionType) { @@ -145,7 +147,9 @@ namespace Aurora.Design.Views.Party break; } } - } + }; + + this.ShowModal(typeof(NewPartyDialog.NewPartyDialog), vm); } }