public override void ShowAlert(View view, DialogScope dialogScope, DialogMode dialogMode)
        {
            var viewHost = GetNewDialogWindow();

            // prepare host view and viewmodel

            viewHost.HostedView = view;

            viewHost.HostedViewModel = view.ViewModel;

            view.ViewModel.InteractionCompleting += viewModel_modalInteractionCompleting;

            PrepareViewForDisplay(viewHost, view);

            viewHost.ShowDialog();
        }
Esempio n. 2
0
 public abstract void ShowAlert(View view, DialogScope dialogScope, DialogMode dialogMode);
Esempio n. 3
0
 /// <summary>
 /// Shows an alert window using default DialogScope and DialogMode.
 /// </summary>
 /// <param name="viewModel"></param>
 public virtual void ShowAlert(View view)
 {
     ShowAlert(view, DialogScope.Default, DialogMode.Default);
 }
Esempio n. 4
0
 /// <summary>
 /// Displays a dialog window to the user.
 /// </summary>
 /// <param name="viewModel"></param>
 /// <param name="dialogScope"></param>
 public abstract void ShowDialog(
     View view, 
     DialogScope dialogScope, 
     DialogMode dialogMode, 
     bool showActivated = true,
     Func<ViewHostWindow> getWindow = null);
Esempio n. 5
0
 /// <summary>
 /// Displays a tool window to the user.
 /// </summary>
 /// <param name="viewModel"></param>
 public abstract void ShowToolWindow(View view, Func<ViewHostWindow> getWindow = null);
        public override void ShowToolWindow(View view, Func<ViewHostWindow> getWindow = null)
        {
            ViewHostWindow viewHost = null;

            // prepare host view and viewmodel
            if (getWindow == null)
            {
                viewHost = GetNewToolWindow();
            }
            else
            {
                viewHost = getWindow();

                if (viewHost is Window)
                    OnAfterWindowCreated(viewHost as Window);
            }

            viewHost.Owner = Application.Current.MainWindow;

            viewHost.HostedView = view;

            viewHost.HostedViewModel = view.ViewModel;

            view.ViewModel.InteractionCompleting += viewModel_nonModalInteractionCompleting;

            viewHost.Closed += (sender, e) =>
            {
                if (view.ViewModel.InteractionOutcome == UserInteractionOutcome.Unset)
                    view.ViewModel.CompleteInteraction(UserInteractionOutcome.Cancelled);
            };

            PrepareViewForDisplay(viewHost, view);

            if (!UIDispatcher.HasShutdownStarted
                && !UIDispatcher.HasShutdownFinished)
            {
                viewHost.Show();
            }
        }
 protected virtual void PrepareViewForDisplay(ViewHostWindow viewHost, View view)
 { }
        public override void ShowDialog(View view, DialogScope dialogScope, DialogMode dialogMode, bool showActivated = true, Func<ViewHostWindow> getWindow = null)
        {
            var viewModel = view.ViewModel;

            ViewHostWindow viewHost = null;

            // prepare host view and viewmodel
            if (getWindow == null)
            {
                viewHost = GetNewDialogWindow();
            }
            else
            {
                viewHost = getWindow();

                if (viewHost is Window)
                    OnAfterWindowCreated(viewHost as Window);
            }

            viewHost.Owner = Application.Current.MainWindow;

            viewHost.HostedViewModel = viewModel;

            viewHost.HostedView = view;

            viewHost.Closed += (sender, e) =>
            {
                if (viewModel.InteractionOutcome == UserInteractionOutcome.Unset)
                    viewModel.CompleteInteraction(UserInteractionOutcome.Cancelled);
            };

            if (dialogMode == DialogMode.Modal)
            {
                viewModel.InteractionCompleting += viewModel_modalInteractionCompleting;
            }
            else
            {
                viewModel.InteractionCompleting += viewModel_nonModalInteractionCompleting;
            }

            if (dialogScope == DialogScope.Global)
            {
                if (viewHost != Application.Current.MainWindow) // this may happen when Visual Studio is closing down
                    viewHost.Owner = Application.Current.MainWindow;
            }

            viewHost.ShowActivated = showActivated;

            PrepareViewForDisplay(viewHost, view);


            if (!UIDispatcher.HasShutdownStarted
                && !UIDispatcher.HasShutdownFinished)
            {
                if (dialogMode == DialogMode.Modal)
                {
                    viewHost.ShowDialog();
                }
                else
                {
                    viewHost.Show();
                }
            }
        }
 public static View GetTarget(View element)
 {
     return (View)element.GetValue(TargetProperty);
 }
 public static void SetTarget(View element, View value)
 {
     element.SetValue(TargetProperty, value);
 }