Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StateChangeEventArgs"/> class.
 /// </summary>
 /// <param name="controlDefinition">The control definition.</param>
 public StateChangeEventArgs(AbstractDemoFlow.ControlDefinition controlDefinition)
 {
     if (controlDefinition == null) throw new ArgumentNullException("controlDefinition");
     ControlDefinition = controlDefinition;
 }
Exemplo n.º 2
0
        /// <summary>
        ///   Updates the current scene in transition presenter.
        /// </summary>
        /// <param name = "controlDefinition">The control definition.</param>
        private void UpdateCurrentSceneInTransitionPresenter(AbstractDemoFlow.ControlDefinition controlDefinition)
        {
            if (controlDefinition == null) throw new ArgumentNullException("controlDefinition");

            // exit the demo if there is no scene left
            if (DemoFlow.CurrentScene == null)
            {
                Close();
                return;
            }

            if (controlDefinition.TransitionType == null)
            {
                // replace the current controls if the new state h
                if (controlDefinition.ControlType != null)
                {
                    TransitionPresenter.Children.Clear();
                    var newContent = (UIElement) ServiceLocator.Current.GetInstance(controlDefinition.ControlType);

                    // a control is brought into view, send it a notification
                    // so it can start its animations
                    XamlHelper.RaiseGotFocusEvent(newContent);

                    TransitionPresenter.Children.Add(newContent);
                }
                return;
            }

            var previousScene = DemoFlow.PreviousState;
            var currentScene = DemoFlow.CurrentScene;

            var previousControlType = previousScene != null ? previousScene.ControlType : null;
            var currentControlType = currentScene.ControlType;

            var previousControl = previousControlType != null
                                      ? (UIElement) ServiceLocator.Current.GetInstance(previousControlType)
                                      : new Canvas();
            var currentControl = currentControlType != null
                                     ? (UIElement) ServiceLocator.Current.GetInstance(currentControlType)
                                     : new Canvas();

            var transition = (ITransition) ServiceLocator.Current.GetInstance(currentScene.TransitionType);

            // a control is brought into view, send it a notification
            // so it can start its animations
            XamlHelper.RaiseGotFocusEvent(currentControl);

            TransitionPresenter.DoTransition(previousControl, currentControl, transition);
        }