public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            FrameworkElement element = null;

            if(handlingNode != null)
                element = handlingNode.UIElement as FrameworkElement;

            if (element == null && message != null)
                element = message.Source.UIElement as FrameworkElement;   

            if(element == null)
            {
                Completed(this, null);
                return;
            }

            var storyboard = (Storyboard)element.Resources[_animationKey];

            if (_wait)
                storyboard.Completed += delegate { Completed(this, null); };

            storyboard.Begin();

            if (!_wait)
                Completed(this, null);
        }
        public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            if(_show)
                ServiceLocator.Current.GetInstance<ILoadScreen>().StartLoading(_message);
            else ServiceLocator.Current.GetInstance<ILoadScreen>().StopLoading();

            Completed(this, null);
        }
Exemple #3
0
        private void OnComplete(Exception exception)
        {
            _enumerator   = null;
            _message      = null;
            _handlingNode = null;

            Completed(this, exception);
        }
        public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            var result = _dialog.ShowDialog().GetValueOrDefault(false);

            if(result)
                Completed(this, null);
            else Completed(this, new CancelResult());
        }
Exemple #5
0
        /// <summary>
        /// Executes the custom code.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            _message      = message;
            _handlingNode = handlingNode;

            _enumerator = _children.GetEnumerator();

            ChildCompleted(null, null);
        }
Exemple #6
0
        /// <summary>
        /// Executes the custom code.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            _message = message;
            _handlingNode = handlingNode;

            _enumerator = _children.GetEnumerator();

            ChildCompleted(null, null);
        }
        public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            var source = (FrameworkElement)message.Source.UIElement;
            var popup = source.FindName("detailsPopup") as Popup;

            popup.IsOpen = true;
            popup.CaptureMouse();
            popup.Child.MouseLeave += (o, e) => popup.IsOpen = false;

            Completed(this, null);
        }
Exemple #8
0
        private void HandleOutcome(IRoutedMessageWithOutcome message, IInteractionNode handlingNode, MessageProcessingOutcome outcome)
        {
            var result = _messageBinder.CreateResult(outcome);

            result.Completed += (r, ex) =>{
                if(ex != null)
                {
                    if(!TryApplyRescue(message, handlingNode, ex))
                        throw ex;
                }

                OnCompleted();
            };

            result.Execute(message, handlingNode);
        }
        public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            var client = new WebClient();

            client.OpenReadCompleted += (s, e) =>{
                if(e.Error != null)
                    Core.Invocation.Execute.OnUIThread(() => Completed(this, e.Error));
                else
                {
                    Stream = e.Result;
                    Core.Invocation.Execute.OnUIThread(() => Completed(this, null));
                }
            };

            client.OpenReadAsync(_uri);
        }
Exemple #10
0
        private void HandleOutcome(IRoutedMessageWithOutcome message, IInteractionNode handlingNode, MessageProcessingOutcome outcome)
        {
            var result = _messageBinder.CreateResult(outcome);

            result.Completed += (r, ex) => {
                if (ex != null)
                {
                    if (!TryApplyRescue(message, handlingNode, ex))
                    {
                        throw ex;
                    }
                }

                OnCompleted();
            };

            result.Execute(message, handlingNode);
        }
        public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            //just demonstrating the power of a custom IExecutableResult

            var source = (FrameworkElement)message.Source.UIElement;
            var popup = source.FindName("dirtyPopup") as Popup;

            var itemsControl = (ItemsControl)popup.FindName("messageHost");
            itemsControl.ItemsSource = _results;

            var visualOffset = source.TransformToVisual(Application.Current.RootVisual).Transform(new Point(0, 0));
            var popupOffset = popup.TransformToVisual(Application.Current.RootVisual).Transform(new Point(0, 0));

            popup.HorizontalOffset = (visualOffset.X - popupOffset.X) / 2;
            popup.IsOpen = true;
            popup.CaptureMouse();

            popup.Child.MouseLeave += delegate { popup.IsOpen = false; };

            Completed(this, null);
        }
 public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
 {
     Execute();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResultExecutionContext"/> class.
 /// </summary>
 /// <param name="serviceLocator">The service locator.</param>
 /// <param name="message">The message.</param>
 /// <param name="handlingNode">The handling node.</param>
 public ResultExecutionContext(IServiceLocator serviceLocator, IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
 {
     this.message        = message;
     this.handlingNode   = handlingNode;
     this.serviceLocator = serviceLocator;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResultExecutionContext"/> class.
 /// </summary>
 /// <param name="serviceLocator">The service locator.</param>
 /// <param name="message">The message.</param>
 /// <param name="handlingNode">The handling node.</param>
 public ResultExecutionContext(IServiceLocator serviceLocator, IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
 {
     this.message = message;
     this.handlingNode = handlingNode;
     this.serviceLocator = serviceLocator;
 }
Exemple #15
0
 public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
 {
     Completed(this, null);
 }
Exemple #16
0
        /// <summary>
        /// Executes the custom code.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        public virtual void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            if (_outcome.WasCancelled)
            {
                Completed(this, null);
                return;
            }

            var element = message.Source.UIElement as FrameworkElement;

            if(element != null)
            {
                if(string.IsNullOrEmpty(message.OutcomePath))
                {
                    var target = element.FindNameExhaustive<object>(message.DefaultOutcomeElement, false);

                    if (target != null)
                    {
                        var defaults = _routedMessageController.FindDefaultsOrFail(target);
                        defaults.SetDefaultValue(target, _outcome.Result);
                    }
                }
                else
                {
                    var parts = message.OutcomePath.Split(_separator, StringSplitOptions.RemoveEmptyEntries);

                    if(parts.Length < 2)
                    {
                        Completed(this, new CaliburnException(string.Format("{0} is not a valid return path.", message.OutcomePath)));
                        return;
                    }

                    var target = element.FindNameExhaustive<object>(parts[0], true);
                    var setter = CreateSetter(target, parts.Skip(1).ToArray());

                    if (setter == null)
                    {
                        Completed(this, new CaliburnException(string.Format("{0} is not a valid property path.", parts.Skip(1).Aggregate((a, c) => a + c))));
                        return;
                    }

                    setter(_outcome.Result);
                }
            }
#if !SILVERLIGHT
            else
            {
                var fce = message.Source.UIElement as FrameworkContentElement;

                if(fce != null)
                {
                    if(string.IsNullOrEmpty(message.OutcomePath))
                    {
                        var target = fce.FindNameExhaustive<object>(message.DefaultOutcomeElement, true);

                        if(target != null)
                        {
                            var defaults = _routedMessageController.FindDefaultsOrFail(target);
                            defaults.SetDefaultValue(target, _outcome.Result);
                        }
                    }
                    else
                    {
                        var parts = message.OutcomePath.Split(_separator, StringSplitOptions.RemoveEmptyEntries);

                        if (parts.Length < 2)
                        {
                            Completed(this, new CaliburnException(string.Format("{0} is not a valid return path.", message.OutcomePath)));
                            return;
                        }

                        var target = fce.FindNameExhaustive<object>(parts[0], true);
                        var setter = CreateSetter(target, parts.Skip(1).ToArray());

                        if(setter == null)
                        {
                            Completed(this, new CaliburnException(string.Format("{0} is not a valid property path.", parts.Skip(1).Aggregate((a, c) => a + c))));
                            return;    
                        }

                        setter(_outcome.Result);
                    }
                }
                else if(!string.IsNullOrEmpty(message.OutcomePath))
                {
                    Completed(this, new CaliburnException("Cannot determine parameters unless handler node is a FrameworkElement or FrameworkContentElement."));
                    return;
                }
            }
#else
            else if (!string.IsNullOrEmpty(message.OutcomePath))
            {
                Completed(this, new CaliburnException("Cannot determine parameters unless handler node is a FrameworkElement or FrameworkContentElement."));
                return;
            }
#endif

            Completed(this, null);
        }
Exemple #17
0
 public void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
 {
     Completed(this, null);
 }
Exemple #18
0
        private void OnComplete(Exception exception) 
        {
            _enumerator = null;
            _message = null;
            _handlingNode = null;

            Completed(this, exception);
        }
Exemple #19
0
        /// <summary>
        /// Executes the custom code.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        public virtual void Execute(IRoutedMessageWithOutcome message, IInteractionNode handlingNode)
        {
            if (_outcome.WasCancelled)
            {
                Completed(this, null);
                return;
            }

            var element = message.Source.UIElement as FrameworkElement;

            if (element != null)
            {
                if (string.IsNullOrEmpty(message.OutcomePath))
                {
                    var target = element.FindNameExhaustive <object>(message.DefaultOutcomeElement, false);

                    if (target != null)
                    {
                        var defaults = _routedMessageController.FindDefaultsOrFail(target);
                        defaults.SetDefaultValue(target, _outcome.Result);
                    }
                }
                else
                {
                    var parts = message.OutcomePath.Split(_separator, StringSplitOptions.RemoveEmptyEntries);

                    if (parts.Length < 2)
                    {
                        Completed(this, new CaliburnException(string.Format("{0} is not a valid return path.", message.OutcomePath)));
                        return;
                    }

                    var target = element.FindNameExhaustive <object>(parts[0], true);
                    var setter = CreateSetter(target, parts.Skip(1).ToArray());

                    if (setter == null)
                    {
                        Completed(this, new CaliburnException(string.Format("{0} is not a valid property path.", parts.Skip(1).Aggregate((a, c) => a + c))));
                        return;
                    }

                    setter(_outcome.Result);
                }
            }
#if !SILVERLIGHT
            else
            {
                var fce = message.Source.UIElement as FrameworkContentElement;

                if (fce != null)
                {
                    if (string.IsNullOrEmpty(message.OutcomePath))
                    {
                        var target = fce.FindNameExhaustive <object>(message.DefaultOutcomeElement, true);

                        if (target != null)
                        {
                            var defaults = _routedMessageController.FindDefaultsOrFail(target);
                            defaults.SetDefaultValue(target, _outcome.Result);
                        }
                    }
                    else
                    {
                        var parts = message.OutcomePath.Split(_separator, StringSplitOptions.RemoveEmptyEntries);

                        if (parts.Length < 2)
                        {
                            Completed(this, new CaliburnException(string.Format("{0} is not a valid return path.", message.OutcomePath)));
                            return;
                        }

                        var target = fce.FindNameExhaustive <object>(parts[0], true);
                        var setter = CreateSetter(target, parts.Skip(1).ToArray());

                        if (setter == null)
                        {
                            Completed(this, new CaliburnException(string.Format("{0} is not a valid property path.", parts.Skip(1).Aggregate((a, c) => a + c))));
                            return;
                        }

                        setter(_outcome.Result);
                    }
                }
                else if (!string.IsNullOrEmpty(message.OutcomePath))
                {
                    Completed(this, new CaliburnException("Cannot determine parameters unless handler node is a FrameworkElement or FrameworkContentElement."));
                    return;
                }
            }