/// <summary> /// Ejecuta una animación sobre un fondo lineal /// </summary> private void ExecuteBrushLinear(FrameworkElement control, BrushLinearActionModel action) { if (action.Start != null || action.End != null) { Brush brushControl = GetBrushFromControl(control); if (brushControl != null && brushControl is LinearGradientBrush) { LinearGradientBrush brush = brushControl as LinearGradientBrush; if (brush != null) { // Cambia el modo de Spread brush.SpreadMethod = ViewTools.Convert(action.SpreadMethod); // Anima el centro if (action.Start != null) { brush.StartPoint = ViewTools.Convert(action.Start); } // Anima el origen if (action.End != null) { brush.EndPoint = ViewTools.Convert(action.End); } } } } }
/// <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); }