Пример #1
0
        /// <summary>
        /// Opens the specified screen.
        /// </summary>
        /// <param name="conductor">The conductor.</param>
        /// <param name="subjectSpecification">The subject.</param>
        /// <param name="callback">Is called with true if the screen is activated.</param>
        public static void ActivateSubject(this IConductor conductor, ISubjectSpecification subjectSpecification, Action<bool> callback)
        {
            var found = conductor.GetConductedItems()
                .OfType<IHaveSubject>()
                .FirstOrDefault(subjectSpecification.Matches);

            EventHandler<ActivationProcessedEventArgs> processed = null;
            processed = (s, e) =>{
                conductor.ActivationProcessed -= processed;
                callback(e.Success);
            };

            conductor.ActivationProcessed += processed;

            if(found != null)
                conductor.ActivateItem(found);
            else subjectSpecification.CreateSubjectHost(viewModelFactory, conductor.ActivateItem);
        }
Пример #2
0
        /// <summary>
        /// Opens the specified screen.
        /// </summary>
        /// <param name="conductor">The conductor.</param>
        /// <param name="subjectSpecification">The subject.</param>
        /// <param name="callback">Is called with true if the screen is activated.</param>
        public static void ActivateSubject(this IConductor conductor, ISubjectSpecification subjectSpecification, Action <bool> callback)
        {
            var found = conductor.GetChildren()
                        .OfType <IHaveSubject>()
                        .FirstOrDefault(subjectSpecification.Matches);

            EventHandler <ActivationProcessedEventArgs> processed = null;

            processed = (s, e) => {
                conductor.ActivationProcessed -= processed;
                callback(e.Success);
            };

            conductor.ActivationProcessed += processed;

            if (found != null)
            {
                conductor.ActivateItem(found);
            }
            else
            {
                subjectSpecification.CreateSubjectHost(viewModelFactory, conductor.ActivateItem);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="OpenScreenSubjectResult"/> class.
 /// </summary>
 /// <param name="subjectSpecification">The subject specification.</param>
 public OpenScreenSubjectResult(ISubjectSpecification subjectSpecification)
 {
     this.subjectSpecification = subjectSpecification;
 }
Пример #4
0
 /// <summary>
 /// Shows a modal dialog base on an <see cref="ISubjectSpecification"/>.
 /// </summary>
 /// <param name="subjectSpecification">The subject specification.</param>
 /// <returns>The result.</returns>
 public static DialogScreenSubjectResult DialogSubject(ISubjectSpecification subjectSpecification)
 {
     return(new DialogScreenSubjectResult(subjectSpecification));
 }
Пример #5
0
 /// <summary>
 /// Shows a child based on a <see cref="ISubjectSpecification"/>.
 /// </summary>
 /// <param name="subjectSpecification">The subject specification.</param>
 /// <returns>The result.</returns>
 public static OpenScreenSubjectResult ChildSubject(ISubjectSpecification subjectSpecification)
 {
     return(new OpenScreenSubjectResult(subjectSpecification));
 }