T EntityOf <T>(CXCursor cursor, Func <T> creator) where T : Entity { Entity e; var key = new CursorKey(cursor); if (_CursorToEntity.TryGetValue(key, out e)) { var t = e as T; if (t == null) { throw new ApplicationException(string.Concat("\"", e.FullName, "\" class mismatch: ", e.GetType().Name, " vs ", typeof(T).Name)); } return(t); } else { var t = _EntityBinder.Entity <T>(cursor, creator); if (t == null) { return(null); } t.Depth = _Depth; _CursorToEntity.Add(key, t); return(t); } }
void KeyScrollAccel(Keys key) { switch (key) { case Keys.Left: // 37 keys |= CursorKey.Left; break; case Keys.Up: // 38 keys |= CursorKey.Up; break; case Keys.Right: // 39 keys |= CursorKey.Right; break; case Keys.Down: // 40 keys |= CursorKey.Down; break; default: return; } if (keys != 0 && keys == last_keys) { key_accel++; if (keys.HasFlag(CursorKey.Left)) { ScrollRelative(-key_accel, 0); } if (keys.HasFlag(CursorKey.Right)) { ScrollRelative(+key_accel, 0); } if (keys.HasFlag(CursorKey.Up)) { ScrollRelative(0, -key_accel); } if (keys.HasFlag(CursorKey.Down)) { ScrollRelative(0, +key_accel); } } else { key_accel = 0; } last_keys = keys; }