Second pass at modal
This commit is contained in:
parent
8affc8d2af
commit
1e7e71f29d
@ -56,7 +56,9 @@ namespace Aurora.Design.Views
|
|||||||
/// <value></value>
|
/// <value></value>
|
||||||
public GetIsPlayingDelegate IsPlaying { get; set; }
|
public GetIsPlayingDelegate IsPlaying { get; set; }
|
||||||
|
|
||||||
public ShowModalDelegate<object> ShowModal { get; set; }
|
public ShowModalDelegate ShowModal { get; set; }
|
||||||
|
|
||||||
|
public HideModalDelegate HideModal { get; set; }
|
||||||
|
|
||||||
|
|
||||||
#endregion Player
|
#endregion Player
|
||||||
|
@ -28,7 +28,9 @@ namespace Aurora.Design.Views.Main
|
|||||||
/// <param name="media"></param>
|
/// <param name="media"></param>
|
||||||
public delegate Task SetPlayerDelegate(BaseMedia media, PlayAction action);
|
public delegate Task SetPlayerDelegate(BaseMedia media, PlayAction action);
|
||||||
public delegate bool GetIsPlayingDelegate();
|
public delegate bool GetIsPlayingDelegate();
|
||||||
public delegate Task<object> ShowModalDelegate<T>(Type view, Type viewModel);
|
public delegate void ShowModalDelegate(Type view, BaseDialogViewModel viewModel);
|
||||||
|
|
||||||
|
public delegate void HideModalDelegate();
|
||||||
public delegate void FinishDialogDelegate();
|
public delegate void FinishDialogDelegate();
|
||||||
|
|
||||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
@ -175,7 +177,8 @@ namespace Aurora.Design.Views.Main
|
|||||||
{
|
{
|
||||||
return _playerService.PlaybackState == PlaybackState.Playing;
|
return _playerService.PlaybackState == PlaybackState.Playing;
|
||||||
};
|
};
|
||||||
vm.ShowModal = this.ShowModal<object>;
|
vm.ShowModal = this.ShowModal;
|
||||||
|
vm.HideModal = this.HideModal;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,40 +237,29 @@ namespace Aurora.Design.Views.Main
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<object> ShowModal<T>(Type view, Type viewModel)
|
private void ShowModal(Type view, BaseDialogViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task<object>.Run(() =>
|
ContentPresenter modalContainer = (ContentPresenter)Modal.FindByName("ViewContent");
|
||||||
{
|
var vw = (View)Activator.CreateInstance(view);
|
||||||
object returnObj = null;
|
|
||||||
|
|
||||||
ContentPresenter modalContainer = (ContentPresenter)Modal.FindByName("ViewContent");
|
vw.BindingContext = viewModel;
|
||||||
var vw = (View)Activator.CreateInstance(view);
|
|
||||||
BaseDialogViewModel vm = (BaseDialogViewModel)Activator.CreateInstance(viewModel);
|
|
||||||
|
|
||||||
vw.BindingContext = vm;
|
//Set modal container content
|
||||||
|
modalContainer.Content = vw;
|
||||||
|
|
||||||
//Set modal container content
|
//Set visibility
|
||||||
modalContainer.Content = vw;
|
ChangeModalVisiblity(true);
|
||||||
|
}
|
||||||
|
|
||||||
//Set visibility
|
private void HideModal()
|
||||||
ChangeModalVisiblity(true);
|
{
|
||||||
|
ChangeModalVisiblity(false);
|
||||||
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 ChangeModalVisiblity(bool isVisible)
|
private void ChangeModalVisiblity(bool isVisible)
|
||||||
{
|
{
|
||||||
Modal.IsVisible = isVisible;
|
Modal.IsVisible = isVisible;
|
||||||
|
Content.IsVisible = !isVisible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -127,10 +127,12 @@ namespace Aurora.Design.Views.Party
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Open host selection modal
|
//Open host selection modal
|
||||||
var modalResult = await this.ShowModal(typeof(NewPartyDialog.NewPartyDialog), typeof(NewPartyDialogViewModel));
|
NewPartyDialogViewModel vm = new NewPartyDialogViewModel();
|
||||||
if (modalResult is ConnectionDetails)
|
ConnectionDetails details = new ConnectionDetails();
|
||||||
|
vm.Finish = () =>
|
||||||
{
|
{
|
||||||
ConnectionDetails details = modalResult as ConnectionDetails;
|
this.HideModal();
|
||||||
|
details = vm.ReturnObject as ConnectionDetails;
|
||||||
_hostname = details.HostName;
|
_hostname = details.HostName;
|
||||||
switch (details.ConnectionType)
|
switch (details.ConnectionType)
|
||||||
{
|
{
|
||||||
@ -145,7 +147,9 @@ namespace Aurora.Design.Views.Party
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
this.ShowModal(typeof(NewPartyDialog.NewPartyDialog), vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user