Ejemplo n.º 1
0
 /// <summary>
 ///		Cambia el tamaño de un control
 /// </summary>
 private void ExecuteResize(TimeLineModel timeLine, FrameworkElement control, ResizeActionModel action)
 {
     if (CheckMustAnimate(action))
     {
         if (action.Width != null)
         {
             CreateDoubleAnimation(control, null, action.Width ?? 100,
                                   new PropertyPath(ComicPageView.PageWidthProperty), action);
         }
         if (action.Height != null)
         {
             CreateDoubleAnimation(control, null, action.Height ?? 100,
                                   new PropertyPath(ComicPageView.PageHeightProperty), action);
         }
     }
     else
     {
         if (action.Width != null)
         {
             ComicPageView.SetPageWidth(control, action.Width ?? 100);
         }
         if (action.Height != null)
         {
             ComicPageView.SetPageHeight(control, action.Height ?? 100);
         }
     }
 }
        /// <summary>
        ///		Carga los datos de un timeline
        /// </summary>
        internal TimeLineModel LoadTimeLine(PageModel page, MLNode nodeML)
        {
            TimeLineModel timeLine = new TimeLineModel(page, nodeML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));

            // Asigna los atributos
            AssignAttributesAction(nodeML, timeLine.Parameters, 0, 3);
            // Carga el contenido del timeLine
            foreach (MLNode childML in nodeML.Nodes)
            {
                ActionBaseModel action = null;

                // Obtiene la acción
                switch (childML.Name)
                {
                case ComicRepositoryConstants.TagActionShowImage:
                    action = new SetVisibilityActionModel(timeLine,
                                                          childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                          childML.Attributes[ComicRepositoryConstants.TagVisible].Value.GetBool(true),
                                                          childML.Attributes[ComicRepositoryConstants.TagOpacity].Value.GetDouble(),
                                                          childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionResize:
                    action = new ResizeActionModel(timeLine,
                                                   childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                   childML.Attributes[ComicRepositoryConstants.TagWidth].Value.GetDouble(),
                                                   childML.Attributes[ComicRepositoryConstants.TagHeight].Value.GetDouble(),
                                                   childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionRotate:
                    action = new RotateActionModel(timeLine,
                                                   childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                   childML.Attributes[ComicRepositoryConstants.TagOriginX].Value.GetDouble(0.5),
                                                   childML.Attributes[ComicRepositoryConstants.TagOriginY].Value.GetDouble(0.5),
                                                   childML.Attributes[ComicRepositoryConstants.TagAngle].Value.GetDouble(0),
                                                   childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionZoom:
                    action = new ZoomActionModel(timeLine,
                                                 childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                 childML.Attributes[ComicRepositoryConstants.TagOriginX].Value.GetDouble(0.5),
                                                 childML.Attributes[ComicRepositoryConstants.TagOriginY].Value.GetDouble(0.5),
                                                 childML.Attributes[ComicRepositoryConstants.TagScaleX].Value.GetDouble(1),
                                                 childML.Attributes[ComicRepositoryConstants.TagScaleY].Value.GetDouble(1),
                                                 childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionTranslate:
                    action = new TranslateActionModel(timeLine,
                                                      childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                      childML.Attributes[ComicRepositoryConstants.TagTop].Value.GetDouble(),
                                                      childML.Attributes[ComicRepositoryConstants.TagLeft].Value.GetDouble(),
                                                      childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagActionSetZIndex:
                    action = new SetZIndexModel(timeLine,
                                                childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true),
                                                childML.Attributes[ComicRepositoryConstants.TagZIndex].Value.GetInt(1));
                    break;

                case ComicRepositoryConstants.TagActionPath:
                    action = new PathActionModel(timeLine,
                                                 childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                 Mediator.CommonRepository.Normalize(childML.Value),
                                                 childML.Attributes[ComicRepositoryConstants.TagRotateWithTangent].Value.GetBool(true),
                                                 childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagSetActionViewBox:
                    action = new BrushViewBoxActionModel(timeLine,
                                                         childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                         Mediator.CommonRepository.GetRectangle(childML.Attributes[ComicRepositoryConstants.TagViewBox].Value),
                                                         Mediator.CommonRepository.GetRectangle(childML.Attributes[ComicRepositoryConstants.TagViewPort].Value),
                                                         Mediator.CommonRepository.ConvertTile(childML.Attributes[ComicRepositoryConstants.TagTileMode].Value),
                                                         childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagSetActionRadialBrush:
                    action = new BrushRadialActionModel(timeLine,
                                                        childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                        Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagCenter].Value),
                                                        Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagOrigin].Value),
                                                        childML.Attributes[ComicRepositoryConstants.TagRadiusX].Value.GetDouble(),
                                                        childML.Attributes[ComicRepositoryConstants.TagRadiusY].Value.GetDouble(),
                                                        childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;

                case ComicRepositoryConstants.TagSetActionLinearBrush:
                    action = new BrushLinearActionModel(timeLine,
                                                        childML.Attributes[ComicRepositoryConstants.TagKey].Value,
                                                        Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagStart].Value),
                                                        Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagEnd].Value),
                                                        Mediator.CommonRepository.GetSpreadMethod(childML.Attributes[ComicRepositoryConstants.TagSpread].Value),
                                                        childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true));
                    break;
                }
                // Si realmente se ha leído alguna acción
                if (action != null)
                {
                    // Asigna los atributos
                    AssignAttributesAction(childML, action.Parameters, timeLine.Parameters.Start, timeLine.Parameters.Duration);
                    // Asigna las funciones
                    LoadEases(action, childML);
                    // Añade la acción al timeline
                    timeLine.Actions.Add(action);
                }
            }
            // Devuelve el timeline
            return(timeLine);
        }