public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers) { State state = _state as State; if (state == null) return null; ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; if (button == System.Windows.Forms.MouseButtons.Right) { result.Target = state; mparams.AbsoluteDrag = true; mparams.AbsoluteOffset = new PointF(location.X - state.Bounds.X, location.Y - state.Bounds.Y); } else { mparams.CornerGrabbed = state.HandleAtLocation(location); if (mparams.CornerGrabbed == -1) return null; result.Target = state; mparams.AbsoluteDrag = false; } return result; }
public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers) { State state = _state as State; if (state == null) return null; ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; if (button == System.Windows.Forms.MouseButtons.Right) { result.Target = state; mparams.AbsoluteDrag = true; mparams.AbsoluteOffset = new PointF(location.X - state.Location.X, location.Y - state.Location.Y); } else { if (!MathUtil.IsPointInPoint(location, state.Location, 4)) return null; result.Target = state; mparams.AbsoluteDrag = false; } return result; }
public void DrawEditable(IEntityState _state) { State state = _state as State; Drawing.TextRect(state.Text, state.Bounds.Location, state.Bounds.Size, state.TextFont, state.TextColor, state.TextAlignment); DrawHandle(state); }
public void DrawEditable(IEntityState _state) { State state = _state as State; Drawing.Rectangle(state.Bounds.Location, state.Bounds.Size, state.Color); DrawHandle(state); }
public void DrawEditable(IEntityState _state) { State state = _state as State; PointF loc = new PointF(state.Location.X - 2, state.Location.Y - 2); Drawing.Rectangle(loc, new Size(4, 4), Color.Red); Drawing.RectangleLine(loc, new Size(4, 4), Color.White); }
public KeyframeAddAction(Layer l, Frameset f, uint targ, IEntityState start, IEntityState end, float interpolation) { LayerIndex = Program.ActiveProject.Layers.IndexOf(l); FramesetIndex = l.Framesets.IndexOf(f); Time = targ; State = start.Interpolate(end, interpolation); }
//constructor public Scorpion(PyramidPanic game, Vector2 position) { this.game = game; this.position = position; this.texture = game.Content.Load<Texture2D>(@"Scorpion/Scorpion"); this.walkLeft = new WalkLeft(this); this.walkRight = new WalkRight(this); this.state = walkLeft; }
//Constructor public Beetle(PyramidPanic game, Vector2 position) { this.game = game; this.position = position; this.texture = game.Content.Load<Texture2D>(@"Beetle\Beetle"); this.walkUp = new WalkUp(this); this.walkDown = new WalkDown(this); this.state = this.walkUp; }
// Maak de constructor public Scorpion(PyramidPanic game, Vector2 position, int speed) { this.position = position; this.game = game; this.speed = speed; this.texture = this.game.Content.Load<Texture2D>(@"PlayScene\Scorpion"); this.walkRight = new WalkRight(this); this.walkLeft = new WalkLeft(this); this.state = this.walkRight; }
public void Read(BinaryReader reader, UInt16 version) { Time = reader.ReadUInt32(); Type type = FileFormat.ResolveEntityStateID(reader.ReadUInt16()); InterpMode = version >= 2 ? (EntityInterpolationMode)Enum.Parse(typeof(EntityInterpolationMode), reader.ReadString()) : EntityInterpolationMode.Linear; Type[] args = { }; object[] values = { }; State = (IEntityState)type.GetConstructor(args).Invoke(values); State.Read(reader, version); }
// Maak de constructor public Beetle(PyramidPanic game, Vector2 position, int speed) { this.position = position; this.game = game; this.speed = speed; this.texture = this.game.Content.Load<Texture2D>(@"PlayScene\Beetle"); this.walkDown = new WalkDown(this); this.walkUp = new WalkUp(this); this.state = this.walkDown; }
public void DrawEditable(IEntityState _state) { State state = _state as State; foreach (Joint point in state.Points) { PointF loc = new PointF(point.Location.X - 2, point.Location.Y - 2); Drawing.Rectangle(loc, new Size(4, 4), Color.Red); Drawing.RectangleLine(loc, new Size(4, 4), Color.White); } }
// Maak de constructor public Explorer(PyramidPanic game, Vector2 position, int speed) { this.position = position; this.game = game; this.speed = speed; this.texture = this.game.Content.Load<Texture2D>(@"PlayScene\Explorer"); this.idle = new ExplorerIdle(this); this.walkRight = new ExplorerWalkRight(this); this.walkLeft = new ExplorerWalkLeft(this); this.walkDown = new ExplorerWalkDown(this); this.state = this.idle; }
//constructor public Explorer(PyramidPanic game, Vector2 position) { this.game = game; this.position = position; this.texture = game.Content.Load<Texture2D>(@"explorer/Explorer"); this.walkUp = new ExplorerWalkUp(this); this.walkDown = new ExplorerWalkDown(this); this.walkRight = new ExplorerWalkRight(this); this.walkLeft = new ExplorerWalkLeft(this); this.idle = new ExplorerIdle(this); this.state = this.idle; }
//Constructor public Scorpion(PyramidPanic game, Vector2 position) { this.game = game; this.position = position; this.collisionRect = new Rectangle((int)this.position.X - 16, (int)this.position.Y - 16, 32, 32); this.texture = game.Content.Load<Texture2D>(@"Scorpion\Scorpion"); this.walkLeft = new WalkLeft(this); this.walkRight = new WalkRight(this); this.state = this.walkRight; }
public void DrawEditable(IEntityState _state) { State state = _state as State; PointF Loc1 = new PointF(state.Handle1.X - 3, state.Handle1.Y - 3); PointF Loc2 = new PointF(state.Handle2.X - 3, state.Handle2.Y - 3); SizeF Siz = new SizeF(6, 6); Drawing.Rectangle(Loc1, Siz, Color.Blue); Drawing.RectangleLine(Loc1, Siz, Color.FromArgb(127, 255 - state.Color.R, 255 - state.Color.G, 255 - state.Color.B)); Drawing.Rectangle(Loc2, Siz, Color.Red); Drawing.RectangleLine(Loc2, Siz, Color.FromArgb(127, 255 - state.Color.R, 255 - state.Color.G, 255 - state.Color.B)); }
//Constructor public Explorer(PyramidPanic game, Vector2 position) { this.game = game; this.position = position; this.texture = game.Content.Load<Texture2D>(@"Explorer\Explorer"); this.collisionRect = new Rectangle((int)position.X - 16, (int)position.Y - 16, 32, 32); this.collisionText = this.game.Content.Load<Texture2D>(@"Scorpion\CollisionText"); this.walkDown = new ExplorerWalkDown(this); this.walkUp = new ExplorerWalkUp(this); this.walkLeft = new ExplorerWalkLeft(this); this.walkRight = new ExplorerWalkRight(this); this.idle = new ExplorerIdle(this); this.idleWalk = new ExplorerIdleWalk(this); this.state = this.idle; }
//Constructor public Beetle(PyramidePanic game, Vector2 position) { // de variable meegegeven in de constructor // game this.game = game; //positie this.position = position; //texture this.texture = game.Content.Load<Texture2D>(@"Beetle\Beetle"); //walkup nieuwe aangemaakt this.walkUp = new WalkUp(this); //walkdown nieuwe aangemaakt this.walkDown = new WalkDown(this); //state this.state = this.walkUp; }
//Constructor public Scorpion(PyramidePanic game, Vector2 position) { // game this.game = game; // positie this.position = position; //plaatje wordt geload this.texture = game.Content.Load<Texture2D>(@"Scorpion\Scorpion"); //walkleft this.walkLeft = new WalkLeft(this); //walkright this.walkRight = new WalkRight(this); //state classe this.state = this.walkRight; this.collisionRect = new Rectangle((int)this.position.X,(int)this.position.Y, 32, 32); }
public override int Update <T>(T entity) { Utils.CheckNull(entity); TypeDescriptor typeDescriptor = TypeDescriptor.GetDescriptor(entity.GetType()); EnsureMappingTypeHasPrimaryKey(typeDescriptor); object keyVal = null; MappingMemberDescriptor keyMemberDescriptor = typeDescriptor.PrimaryKey; MemberInfo keyMember = keyMemberDescriptor.MemberInfo; IEntityState entityState = this.TryGetTrackedEntityState(entity); Dictionary <MappingMemberDescriptor, DbExpression> updateColumns = new Dictionary <MappingMemberDescriptor, DbExpression>(); foreach (var kv in typeDescriptor.MappingMemberDescriptors) { var member = kv.Key; var memberDescriptor = kv.Value; if (member == keyMember) { keyVal = memberDescriptor.GetValue(entity); keyMemberDescriptor = memberDescriptor; continue; } AutoIncrementAttribute attr = (AutoIncrementAttribute)memberDescriptor.GetCustomAttribute(typeof(AutoIncrementAttribute)); if (attr != null) { continue; } var val = memberDescriptor.GetValue(entity); if (entityState != null && !entityState.IsChanged(member, val)) { continue; } DbExpression valExp = DbExpression.Parameter(val, memberDescriptor.MemberInfoType); updateColumns.Add(memberDescriptor, valExp); } if (keyVal == null) { throw new Exception(string.Format("实体主键 {0} 值为 null", keyMember.Name)); } if (updateColumns.Count == 0) { return(0); } DbExpression left = new DbColumnAccessExpression(typeDescriptor.Table, keyMemberDescriptor.Column); DbExpression right = DbExpression.Parameter(keyVal, keyMemberDescriptor.MemberInfoType); DbExpression conditionExp = new DbEqualExpression(left, right); DbUpdateExpression e = new DbUpdateExpression(typeDescriptor.Table, conditionExp); foreach (var item in updateColumns) { e.UpdateColumns.Add(item.Key.Column, item.Value); } int ret = this.ExecuteSqlCommand(e); if (entityState != null) { entityState.Refresh(); } return(ret); }
public IEntityState Interpolate(IEntityState target, float interpolationAmount) { return PointLight._Interpolate(interpolationAmount, this, target, EntityInterpolationMode.Linear); }
public void ProgressState() { NextState = new AIWaitState(); IsComplete = true; aiController.SendOnAITurnComplete(); }
public void Draw(IEntityState _state) { State state = _state as State; Root.Draw(state.Root); }
public ManipulateResult TryManipulate(IEntityState _state, Point location, MouseButtons button, Keys modifiers) { State state = _state as State; if (state == null) { return(null); } ManipulateResult result = new ManipulateResult(); ManipulateParams mparams = new ManipulateParams(); result.Params = mparams; if (modifiers == Keys.Shift) { mparams.PivotDrag = true; } else if (modifiers == Keys.Alt) { mparams.DisableIK = true; } if (button == MouseButtons.Right) { result.Target = state.Root; mparams.AbsoluteDrag = true; mparams.AbsoluteOffset = new PointF(location.X - state.Root.Location.X, location.Y - state.Root.Location.Y); } else { Joint.State target = state.Root.JointAtLocation(location); if (target == null) { return(null); } if (mparams.PivotDrag && target.Parent != null) { mparams.PivotLength = (float)MathUtil.Length(target.Location, target.Parent.Location); mparams.PivotAngle = (float)MathUtil.Angle(target.Location, target.Parent.Location); // you need to go through every descendant (not child) of target here and store their angle and distance to target's parent mparams.PivotInfo = new Dictionary <Joint.State, Tuple <float, float> >(); Stack <Joint.State> open = new Stack <Joint.State>(); open.Push(target); while (open.Count > 0) { Joint.State current = open.Pop(); foreach (Joint.State child in current.Children) { open.Push(child); float distance = (float)MathUtil.Length(target.Parent.Location, child.Location); float angle = (float)MathUtil.Angle(child.Location, target.Parent.Location); // or the other way around, depends mparams.PivotInfo[child] = new Tuple <float, float>(distance, angle); } } } result.Target = target; mparams.AbsoluteDrag = false; } return(result); }
public void DrawEditable(IEntityState _state) { }
private static IEntityState _Interpolate(float t, IEntityState _current, IEntityState _target, EntityInterpolationMode mode) { State current = _current as State; State target = _target as State; State state = new State(); state.Location = Interpolation.Interpolate(t, current.Location, target.Location, mode); state.LightRadius = Interpolation.Interpolate(t, current.LightRadius, target.LightRadius, mode); state.LightColor = Interpolation.Interpolate(t, current.LightColor, target.LightColor, mode); state.LightAttenuation = Interpolation.Interpolate(t, current.LightAttenuation, target.LightAttenuation, mode); return state; }
public void ProgressState() { NextState = new PlayerWaitState(new PlayerSolutionAcquisitionState()); IsComplete = true; }
public CompanyController(ICustomerContext db, IEntityState state, IRequestProxy requestProxy) : base(db, state, requestProxy) { }
private void Start() { //TEST //currentState = new ES_Wander(this.gameObject, 5, new Vector2(3, 3)); currentState = new ES_Task(this.GetComponent <EntityTaskExecuter>()); }
public PlayerWaitState(IEntityState nextState) { NextState = nextState; }
protected override async Task <int> Update <TEntity>(TEntity entity, string table, bool @async) { PublicHelper.CheckNull(entity); TypeDescriptor typeDescriptor = EntityTypeContainer.GetDescriptor(typeof(TEntity)); PublicHelper.EnsureHasPrimaryKey(typeDescriptor); PairList <PrimitivePropertyDescriptor, object> keyValues = new PairList <PrimitivePropertyDescriptor, object>(typeDescriptor.PrimaryKeys.Count); IEntityState entityState = this.TryGetTrackedEntityState(entity); Dictionary <PrimitivePropertyDescriptor, DbExpression> updateColumns = new Dictionary <PrimitivePropertyDescriptor, DbExpression>(); foreach (PrimitivePropertyDescriptor propertyDescriptor in typeDescriptor.PrimitivePropertyDescriptors) { if (propertyDescriptor.IsPrimaryKey) { var keyValue = propertyDescriptor.GetValue(entity); PrimaryKeyHelper.KeyValueNotNull(propertyDescriptor, keyValue); keyValues.Add(propertyDescriptor, keyValue); continue; } if (propertyDescriptor.IsAutoIncrement || propertyDescriptor.HasSequence() || propertyDescriptor.IsRowVersion) { continue; } object val = propertyDescriptor.GetValue(entity); PublicHelper.NotNullCheck(propertyDescriptor, val); if (entityState != null && !entityState.HasChanged(propertyDescriptor, val)) { continue; } DbExpression valExp = DbExpression.Parameter(val, propertyDescriptor.PropertyType, propertyDescriptor.Column.DbType); updateColumns.Add(propertyDescriptor, valExp); } object rowVersionNewValue = null; if (typeDescriptor.HasRowVersion()) { var rowVersionDescriptor = typeDescriptor.RowVersion; var rowVersionOldValue = rowVersionDescriptor.GetValue(entity); rowVersionNewValue = PublicHelper.IncreaseRowVersionNumber(rowVersionOldValue); updateColumns.Add(rowVersionDescriptor, DbExpression.Parameter(rowVersionNewValue, rowVersionDescriptor.PropertyType, rowVersionDescriptor.Column.DbType)); keyValues.Add(rowVersionDescriptor, rowVersionOldValue); } if (updateColumns.Count == 0) { return(0); } DbTable dbTable = PublicHelper.CreateDbTable(typeDescriptor, table); DbExpression conditionExp = PublicHelper.MakeCondition(keyValues, dbTable); DbUpdateExpression e = new DbUpdateExpression(dbTable, conditionExp); foreach (var item in updateColumns) { e.UpdateColumns.Add(item.Key.Column, item.Value); } int rowsAffected = await this.ExecuteNonQuery(e, @async); if (typeDescriptor.HasRowVersion()) { PublicHelper.CauseErrorIfOptimisticUpdateFailed(rowsAffected); typeDescriptor.RowVersion.SetValue(entity, rowVersionNewValue); } if (entityState != null) { entityState.Refresh(); } return(rowsAffected); }
public void DrawEditable(IEntityState _state) { State state = _state as State; Root.DrawHandle(state.Root); }
public void ProgressState() { NextState = new PlayerWaitState(new PlayerSolutionAcquisitionState()); IsComplete = true; playerController.SendOnPlayerTurnComplete(); }
public void Draw(IEntityState _state) { State state = _state as State; Drawing.Bitmap(state.Bounds.Location, state.Bounds.Size, state.Rotation, state.BitmapAlpha, TextureID); }
/// <summary> /// Is the given state object a state for the given entity? /// </summary> public static bool IsStateOf(this IEntityState state, IEntity entity) { return((state != null) && (entity != null) && (state.EntityId == entity.Id)); }
internal void Tick(uint tick) { if (IsServer) { using (PooledBitStream stream = PooledBitStream.Get()) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { writer.WriteUInt32(tick); Dictionary <ulong, IEntityState> states = new Dictionary <ulong, IEntityState>(entities.Count); foreach (Entity entity in entities.Values) { IEntityState state = entity.DoStateTick(tick); if (state != null) { states.Add(entity.NetworkId, state); } } writer.WriteInt32(states.Count); foreach (var state in states) { writer.WriteUInt64(state.Key); state.Value.Serialize(writer); } CustomMessagingManager.SendNamedMessage("NetworkState", null, stream); } } } else { foreach (Entity entity in entities.Values) { entity.DoStateTick(tick); } uint predictTicks = (uint)Math.Ceiling(RTT / FixedStep) + 2 * Deviation; for (uint i = 0; i < predictTicks; i++) { if (tick + i > LastPredictedTick) { using (PooledBitStream stream = PooledBitStream.Get()) { using (PooledBitWriter writer = PooledBitWriter.Get(stream)) { LastPredictedTick = tick + i; var authEntities = entities.Values.Where(e => e.IsOwner); int count = authEntities.Count(); Dictionary <ulong, IEntityInput> inputs = new Dictionary <ulong, IEntityInput>(count); foreach (Entity entity in authEntities) { IEntityInput input = entity.DoInputTick(tick + i); if (input != null) { inputs.Add(entity.NetworkId, input); } } writer.WriteUInt32(tick + i); writer.WriteInt32(inputs.Count); foreach (var input in inputs) { writer.WriteUInt64(input.Key); input.Value.Serialize(writer); } CustomMessagingManager.SendNamedMessage("NetworkInput", NetworkingManager.Singleton.ServerClientId, stream); } } } foreach (Entity entity in entities.Values.Where(e => e.extrapolate || e.IsOwner)) { entity.DoStateTick(tick + i); } } foreach (Entity entity in entities.Values) { entity.Present(); } } }
public void Draw(IEntityState _state) { State state = _state as State; Drawing.PointLight(state.Location, state.LightColor, state.LightAttenuation, state.LightRadius); }
public Keyframe(UInt32 time, IEntityState state, EntityInterpolationMode interpMode) { Time = time; State = state; InterpMode = interpMode; }
public override int Update <TEntity>(TEntity entity, string table) { PublicHelper.CheckNull(entity); TypeDescriptor typeDescriptor = EntityTypeContainer.GetDescriptor(typeof(TEntity)); PublicHelper.EnsureHasPrimaryKey(typeDescriptor); Dictionary <PropertyDescriptor, object> keyValueMap = PrimaryKeyHelper.CreateKeyValueMap(typeDescriptor); IEntityState entityState = this.TryGetTrackedEntityState(entity); Dictionary <PropertyDescriptor, DbExpression> updateColumns = new Dictionary <PropertyDescriptor, DbExpression>(); PropertyDescriptor timestampProperty = null; object timestampValue = null; foreach (PropertyDescriptor propertyDescriptor in typeDescriptor.PropertyDescriptors) { if (propertyDescriptor.IsPrimaryKey) { keyValueMap[propertyDescriptor] = propertyDescriptor.GetValue(entity); continue; } if (propertyDescriptor.IsAutoIncrement || propertyDescriptor.HasSequence()) { continue; } if (propertyDescriptor.IsTimestamp()) { timestampProperty = propertyDescriptor; timestampValue = propertyDescriptor.GetValue(entity); continue; } object val = propertyDescriptor.GetValue(entity); if (entityState != null && !entityState.HasChanged(propertyDescriptor, val)) { continue; } DbExpression valExp = DbExpression.Parameter(val, propertyDescriptor.PropertyType, propertyDescriptor.Column.DbType); updateColumns.Add(propertyDescriptor, valExp); } if (updateColumns.Count == 0) { return(0); } DbTable dbTable = table == null ? typeDescriptor.Table : new DbTable(table, typeDescriptor.Table.Schema); if (timestampValue != null) { keyValueMap[timestampProperty] = timestampValue; } DbExpression conditionExp = PrimaryKeyHelper.MakeCondition(keyValueMap, dbTable); DbUpdateExpression e = new DbUpdateExpression(dbTable, conditionExp); foreach (var item in updateColumns) { e.UpdateColumns.Add(item.Key.Column, item.Value); } int rowsAffected = 0; if (timestampValue == null) { rowsAffected = this.ExecuteNonQuery(e); if (entityState != null) { entityState.Refresh(); } return(rowsAffected); } List <Action <TEntity, IDataReader> > mappers = new List <Action <TEntity, IDataReader> >(); mappers.Add(GetMapper <TEntity>(timestampProperty, e.Returns.Count)); e.Returns.Add(timestampProperty.Column); IDataReader dataReader = this.ExecuteReader(e); using (dataReader) { while (dataReader.Read()) { rowsAffected++; foreach (var mapper in mappers) { mapper(entity, dataReader); } } } if (entityState != null) { entityState.Refresh(); } return(rowsAffected); }
public void SetColor(IEntityState _state, Color color) { State state = _state as State; state.Root.SetColor(color, null); }
public Keyframe() { Time = 0; State = null; InterpMode = EntityInterpolationMode.Linear; }
public void ProgressState() { NextState = new PlayerFireState(); IsComplete = true; }
public IEntityState Interpolate(IEntityState target, float interpolationAmount) { return(CircleObject._Interpolate(interpolationAmount, this, target, EntityInterpolationMode.Linear)); }
public override int Update <TEntity>(TEntity entity, string table) { Utils.CheckNull(entity); TypeDescriptor typeDescriptor = TypeDescriptor.GetDescriptor(entity.GetType()); EnsureMappingTypeHasPrimaryKey(typeDescriptor); Dictionary <MappingMemberDescriptor, object> keyValueMap = CreateKeyValueMap(typeDescriptor); IEntityState entityState = this.TryGetTrackedEntityState(entity); Dictionary <MappingMemberDescriptor, DbExpression> updateColumns = new Dictionary <MappingMemberDescriptor, DbExpression>(); foreach (var kv in typeDescriptor.MappingMemberDescriptors) { MappingMemberDescriptor memberDescriptor = kv.Value; if (keyValueMap.ContainsKey(memberDescriptor)) { keyValueMap[memberDescriptor] = memberDescriptor.GetValue(entity); continue; } SequenceAttribute attr = (SequenceAttribute)memberDescriptor.GetCustomAttribute(typeof(SequenceAttribute)); if (attr != null) { continue; } object val = memberDescriptor.GetValue(entity); if (entityState != null && !entityState.HasChanged(memberDescriptor, val)) { continue; } DbExpression valExp = DbExpression.Parameter(val, memberDescriptor.MemberInfoType); updateColumns.Add(memberDescriptor, valExp); } if (updateColumns.Count == 0) { return(0); } DbTable dbTable = table == null ? typeDescriptor.Table : new DbTable(table, typeDescriptor.Table.Schema); DbExpression conditionExp = MakeCondition(keyValueMap, dbTable); DbUpdateExpression e = new DbUpdateExpression(dbTable, conditionExp); foreach (var item in updateColumns) { e.UpdateColumns.Add(item.Key.Column, item.Value); } int ret = this.ExecuteSqlCommand(e); if (entityState != null) { entityState.Refresh(); } return(ret); }
public virtual int Update <TEntity>(TEntity entity, string table) { Utils.CheckNull(entity); TypeDescriptor typeDescriptor = TypeDescriptor.GetDescriptor(entity.GetType()); EnsureEntityHasPrimaryKey(typeDescriptor); MappingMemberDescriptor keyMemberDescriptor = typeDescriptor.PrimaryKey; MemberInfo keyMember = keyMemberDescriptor.MemberInfo; object keyVal = null; IEntityState entityState = this.TryGetTrackedEntityState(entity); Dictionary <MappingMemberDescriptor, DbExpression> updateColumns = new Dictionary <MappingMemberDescriptor, DbExpression>(); foreach (var kv in typeDescriptor.MappingMemberDescriptors) { MemberInfo member = kv.Key; MappingMemberDescriptor memberDescriptor = kv.Value; if (member == keyMember) { keyVal = memberDescriptor.GetValue(entity); keyMemberDescriptor = memberDescriptor; continue; } if (memberDescriptor.IsAutoIncrement) { continue; } object val = memberDescriptor.GetValue(entity); if (entityState != null && !entityState.HasChanged(memberDescriptor, val)) { continue; } DbExpression valExp = DbExpression.Parameter(val, memberDescriptor.MemberInfoType); updateColumns.Add(memberDescriptor, valExp); } if (keyVal == null) { throw new ChloeException(string.Format("The primary key '{0}' could not be null.", keyMember.Name)); } if (updateColumns.Count == 0) { return(0); } DbTable dbTable = table == null ? typeDescriptor.Table : new DbTable(table, typeDescriptor.Table.Schema); DbExpression left = new DbColumnAccessExpression(dbTable, keyMemberDescriptor.Column); DbExpression right = DbExpression.Parameter(keyVal, keyMemberDescriptor.MemberInfoType); DbExpression conditionExp = new DbEqualExpression(left, right); DbUpdateExpression e = new DbUpdateExpression(dbTable, conditionExp); foreach (var item in updateColumns) { e.UpdateColumns.Add(item.Key.Column, item.Value); } int ret = this.ExecuteSqlCommand(e); if (entityState != null) { entityState.Refresh(); } return(ret); }
public void Draw(IEntityState _state) { State state = _state as State; Drawing.Rectangle(state.Bounds.Location, state.Bounds.Size, state.Color); }
public void SetColor(IEntityState _state, Color color) { State state = _state as State; state.Color = color; }
public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers, bool fromEditor) { return TryManipulate(_state, location, button, modifiers); }
public void EnterState(Entity entity, IEntityState oldState) { }
public void Draw(IEntityState _state) { State state = _state as State; Drawing.CappedLine(state.Handle1, state.Handle2, state.Thickness, state.Color); }
public IEntityState Interpolate(IEntityState target, float interpolationAmount) { return CircleObject._Interpolate(interpolationAmount, this, target, EntityInterpolationMode.Linear); }
public ManipulateResult TryManipulate(IEntityState _state, Point location, System.Windows.Forms.MouseButtons button, System.Windows.Forms.Keys modifiers, bool fromEditor) { return(TryManipulate(_state, location, button, modifiers)); }
/// <summary> /// Is the given state object a state for the given entity? /// </summary> public static bool IsStateOf <T>(this IEntityState <T> state, T entity) where T : class, IEntity { return((state != null) && (entity != null) && (state.EntityId == entity.Id)); }
public IEntityState Interpolate(float t, IEntityState _current, IEntityState _target, EntityInterpolationMode mode) { return(_Interpolate(t, _current, _target, mode)); }
private static IEntityState _Interpolate(float t, IEntityState _current, IEntityState _target, EntityInterpolationMode mode) { State current = _current as State; State target = _target as State; State state = new State(); state.Bounds = Interpolation.Interpolate(t, current.Bounds, target.Bounds, mode); state.Text = current.Text; state.TextAlignment = current.TextAlignment; state.TextFont = current.TextFont; state.TextColor = Interpolation.Interpolate(t, current.TextColor, target.TextColor, mode); return state; }
public virtual void ChangeState(IEntityState <EntityState> newState) { CurrentState.Exit(); CurrentState = newState; CurrentState.Enter(); }
public IEntityState Interpolate(float t, IEntityState _current, IEntityState _target, EntityInterpolationMode mode) { return _Interpolate(t, _current, _target, mode); }
public IEntityState Interpolate(IEntityState target, float interpolationAmount) { return(StickFigure._Interpolate(interpolationAmount, this, target, EntityInterpolationMode.Linear)); }
public void GLContext_MouseDown(object sender, MouseEventArgs e) { ActiveDragObject = null; Timeline timeline = Program.MainTimeline; if (timeline.SelectedLayer == null) return; if (timeline.SelectedKeyframe == null) return; if (timeline.SelectedLayer.Data.GetType() == typeof(StickFigure) || timeline.SelectedLayer.Data.GetType() == typeof(CustomFigure)) StickFigurePair = StickFigure.FindJointStatePair(((StickFigure)timeline.SelectedLayer.Data).Root, ((StickFigure.State)timeline.SelectedKeyframe.State).Root, e.Location); ManipulateResult result = timeline.SelectedLayer.Data.TryManipulate( timeline.SelectedKeyframe.State, e.Location, e.Button, ModifierKeys); if (result != null) { ActiveDragObject = result.Target; ActiveDragParams = result.Params; LastDragObject = result.Target; ActiveDragPrevState = timeline.SelectedKeyframe.State.Copy(); Program.Form_Properties.UpdateStickFigurePanel(); } }
protected override async Task <int> Update <TEntity>(TEntity entity, string table, bool @async) { PublicHelper.CheckNull(entity); TypeDescriptor typeDescriptor = EntityTypeContainer.GetDescriptor(typeof(TEntity)); PublicHelper.EnsureHasPrimaryKey(typeDescriptor); PairList <PrimitivePropertyDescriptor, object> keyValues = new PairList <PrimitivePropertyDescriptor, object>(typeDescriptor.PrimaryKeys.Count); IEntityState entityState = this.TryGetTrackedEntityState(entity); Dictionary <PrimitivePropertyDescriptor, DbExpression> updateColumns = new Dictionary <PrimitivePropertyDescriptor, DbExpression>(); foreach (PrimitivePropertyDescriptor propertyDescriptor in typeDescriptor.PrimitivePropertyDescriptors) { if (propertyDescriptor.IsPrimaryKey) { var keyValue = propertyDescriptor.GetValue(entity); PrimaryKeyHelper.KeyValueNotNull(propertyDescriptor, keyValue); keyValues.Add(propertyDescriptor, keyValue); continue; } if (propertyDescriptor.CannotUpdate()) { continue; } object val = propertyDescriptor.GetValue(entity); PublicHelper.NotNullCheck(propertyDescriptor, val); if (entityState != null && !entityState.HasChanged(propertyDescriptor, val)) { continue; } DbExpression valExp = DbExpression.Parameter(val, propertyDescriptor.PropertyType, propertyDescriptor.Column.DbType); updateColumns.Add(propertyDescriptor, valExp); } PrimitivePropertyDescriptor rowVersionDescriptor = null; object rowVersionValue = null; object rowVersionNewValue = null; if (typeDescriptor.HasRowVersion()) { rowVersionDescriptor = typeDescriptor.RowVersion; if (rowVersionDescriptor.IsTimestamp()) { rowVersionValue = rowVersionDescriptor.GetValue(entity); this.EnsureRowVersionValueIsNotNull(rowVersionValue); keyValues.Add(rowVersionDescriptor, rowVersionValue); } else { rowVersionValue = rowVersionDescriptor.GetValue(entity); rowVersionNewValue = PublicHelper.IncreaseRowVersionNumber(rowVersionValue); updateColumns.Add(rowVersionDescriptor, DbExpression.Parameter(rowVersionNewValue, rowVersionDescriptor.PropertyType, rowVersionDescriptor.Column.DbType)); keyValues.Add(rowVersionDescriptor, rowVersionValue); } } if (updateColumns.Count == 0) { return(0); } DbTable dbTable = PublicHelper.CreateDbTable(typeDescriptor, table); DbExpression conditionExp = PublicHelper.MakeCondition(keyValues, dbTable); DbUpdateExpression e = new DbUpdateExpression(dbTable, conditionExp); foreach (var item in updateColumns) { e.UpdateColumns.Add(item.Key.Column, item.Value); } int rowsAffected = 0; if (rowVersionDescriptor == null) { rowsAffected = await this.ExecuteNonQuery(e, @async); if (entityState != null) { entityState.Refresh(); } return(rowsAffected); } if (rowVersionDescriptor.IsTimestamp()) { List <Action <TEntity, IDataReader> > mappers = new List <Action <TEntity, IDataReader> >(); mappers.Add(GetMapper <TEntity>(rowVersionDescriptor, e.Returns.Count)); e.Returns.Add(rowVersionDescriptor.Column); IDataReader dataReader = await this.ExecuteReader(e, @async); using (dataReader) { while (dataReader.Read()) { rowsAffected++; foreach (var mapper in mappers) { mapper(entity, dataReader); } } } PublicHelper.CauseErrorIfOptimisticUpdateFailed(rowsAffected); } else { rowsAffected = await this.ExecuteNonQuery(e, @async); PublicHelper.CauseErrorIfOptimisticUpdateFailed(rowsAffected); rowVersionDescriptor.SetValue(entity, rowVersionNewValue); } if (entityState != null) { entityState.Refresh(); } return(rowsAffected); }