/* * 添加一个控件 */ public DControlAnimation insert(DControlAnimation entity) { String sql = "insert into dControlAnimation(dControlId,name,type,delaySeconds,durationSeconds,playTimes,isSameSpeed,isSameOpacity) "; sql = sql + " values(@dControlId,@name,@type,@delaySeconds,@durationSeconds,@playTimes,@isSameSpeed,@isSameOpacity);select last_insert_rowid();"; SQLiteParameter[] parameters = { new SQLiteParameter("@dControlId", DbType.Int32, 4), new SQLiteParameter("@name", DbType.String, 30), new SQLiteParameter("@type", DbType.Int32, 4), new SQLiteParameter("@delaySeconds", DbType.Int32, 4), new SQLiteParameter("@durationSeconds", DbType.Int32, 4), new SQLiteParameter("@playTimes", DbType.Int32, 4), new SQLiteParameter("@isSameSpeed", DbType.Int32, 4), new SQLiteParameter("@isSameOpacity", DbType.Int32, 4) }; parameters[0].Value = entity.dControlId; parameters[1].Value = entity.name; parameters[2].Value = entity.type; parameters[3].Value = entity.delaySeconds; parameters[4].Value = entity.durationSeconds; parameters[5].Value = entity.playTimes; parameters[6].Value = entity.isSameSpeed; parameters[7].Value = entity.isSameOpacity; DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters); int id = DataType.ToInt32(dt.Rows[0]["last_insert_rowid()"].ToString()); entity.id = id; return(entity); }
/* * 更新 */ public int update(DControlAnimation entity) { string sql = "update dControlAnimation set dControlId=@dControlId,name=@name,type=@type" + ",delaySeconds=@delaySeconds,durationSeconds=@durationSeconds" + ",playTimes=@playTimes,isSameSpeed=@isSameSpeed,isSameOpacity=@isSameOpacity" + " where id=@id"; SQLiteParameter[] parameters = { new SQLiteParameter("@dControlId", DbType.Int32, 4), new SQLiteParameter("@name", DbType.String, 30), new SQLiteParameter("@type", DbType.Int32, 4), new SQLiteParameter("@delaySeconds", DbType.Int32, 4), new SQLiteParameter("@durationSeconds", DbType.Int32, 4), new SQLiteParameter("@playTimes", DbType.Int32, 4), new SQLiteParameter("@isSameSpeed", DbType.Int32, 4), new SQLiteParameter("@isSameOpacity", DbType.Int32, 4), new SQLiteParameter("@id", DbType.Int32, 4) }; parameters[0].Value = entity.dControlId; parameters[1].Value = entity.name; parameters[2].Value = entity.type; parameters[3].Value = entity.delaySeconds; parameters[4].Value = entity.durationSeconds; parameters[5].Value = entity.playTimes; parameters[6].Value = entity.isSameSpeed; parameters[7].Value = entity.isSameOpacity; parameters[8].Value = entity.id; int result = Common.SQLiteHelper.ExecuteNonQuery(sql, parameters); return(result); }
/* * 伴随动透明度动画1 * * @param DControlAnimation animation 动画数据 * @param double fromValue 开始值 * @param double toValue 结束值 * */ public static void andBeginOpacityAnimation(FrameworkElement element, DControlAnimation animation, double fromValue, double toValue) { IEasingFunction easingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; andBeginOpacityAnimation(element, animation, fromValue, toValue, easingFunction); }
/* * 初始化一个动作1 * * @param DControlAnimation animation 动画数据 * @param double fromValue 开始值 * @param double toValue 结束值 * */ public static DoubleAnimation initDoubleAnimation(DControlAnimation animation, double fromValue, double toValue) { IEasingFunction easingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut }; return(initDoubleAnimation(animation, fromValue, toValue, easingFunction)); }
/* * 复制添加 */ private void insert(DControlAnimation dControlAnimation, int toDControlId) { DControlAnimation entity = new DControlAnimation(); entity.dControlId = toDControlId; entity.name = dControlAnimation.name; entity.type = dControlAnimation.type; entity.delaySeconds = dControlAnimation.delaySeconds; entity.durationSeconds = dControlAnimation.durationSeconds; entity.playTimes = dControlAnimation.playTimes; entity.isSameOpacity = dControlAnimation.isSameOpacity; entity.isSameSpeed = dControlAnimation.isSameSpeed; insert(entity); }
/* * 初始化一个动作2 * * @param DControlAnimation animation 动画数据 * @param double fromValue 开始值 * @param double toValue 结束值 * @param IEasingFunction easingFunction 缓动函数 * */ public static DoubleAnimation initDoubleAnimation(DControlAnimation animation, double fromValue, double toValue, IEasingFunction easingFunction) { DoubleAnimation da = new DoubleAnimation(fromValue, toValue, new Duration(TimeSpan.FromMilliseconds(animation.durationSeconds))); da.BeginTime = TimeSpan.FromMilliseconds(animation.delaySeconds); if (!animation.isSameSpeed) { da.EasingFunction = easingFunction; } if (animation.playTimes <= 0) { da.RepeatBehavior = RepeatBehavior.Forever; } else { da.RepeatBehavior = new RepeatBehavior(animation.playTimes); } return(da); }
/* * 伴随动透明度动画2 * * @param DControlAnimation animation 动画数据 * @param double fromValue 开始值 * @param double toValue 结束值 * @param IEasingFunction easingFunction 缓动函数 * */ public static void andBeginOpacityAnimation(FrameworkElement element, DControlAnimation animation, double fromValue, double toValue, IEasingFunction easingFunction) { if (animation.isSameOpacity) { return; } element.Opacity = 0; DoubleAnimation da = new DoubleAnimation(fromValue, toValue, new Duration(TimeSpan.FromMilliseconds(animation.durationSeconds))); da.BeginTime = TimeSpan.FromMilliseconds(animation.delaySeconds); if (!animation.isSameSpeed) { da.EasingFunction = easingFunction; } if (animation.playTimes <= 0) { da.RepeatBehavior = RepeatBehavior.Forever; } else { da.RepeatBehavior = new RepeatBehavior(animation.playTimes); } element.BeginAnimation(UIElement.OpacityProperty, da); }
/* * 更新动画 */ public int update(DControlAnimation animation) { return(dControlAnimationDal.update(animation)); }
/* * 添加 */ public DControlAnimation insert(DControlAnimation dControlAnimation) { return(dControlAnimationDal.insert(dControlAnimation)); }