/// <summary> /// Serialization /// </summary> /// <param name="info">Serialization info</param> /// <param name="context">Serialization context</param> /// <param name="id">Unique id for case when face is deserialized from a source file /// in the range [0 numFaces]. VAlue is -1 when face is deserialized by facedetection in a photo</param> /// <param name="serializeID">Unique serialization ID</param> /// <param name="serializeOffset">Unique offset. Used when more than 1 face comes from the same source photo</param> public void GetObjectData(SerializationInfo info, StreamingContext context, int id, int serializeID, int serializeOffset) { if (id >= 0) { info.AddValue("FaceID" + id.ToString(), MyID); serializeID = MyID; } info.AddValue("_FacePathName" + serializeID.ToString() + "_" + serializeOffset.ToString(), _pathName); info.AddValue("_FacePhotoID" + serializeID.ToString() + "_" + serializeOffset.ToString(), _photoID); // This would be the first guess serialization //info.AddValue("_FaceParentID" + serializeID.ToString() + "_" + serializeOffset.ToString(), _parentID); // However when face is deserialized it is by default made a child of the mainCanvas info.AddValue("_FaceParentID" + serializeID.ToString() + "_" + serializeOffset.ToString(), 0); info.AddValue("_FaceParentGroupID" + serializeID.ToString() + "_" + serializeOffset.ToString(), _parentGroupID); info.AddValue("_FaceParentPhotoID" + serializeID.ToString() + "_" + serializeOffset.ToString(), _parentPhotoID); info.AddValue("FaceLeft" + serializeID.ToString() + "_" + serializeOffset.ToString(), Canvas.GetLeft(this)); info.AddValue("FaceTop" + serializeID.ToString() + "_" + serializeOffset.ToString(), Canvas.GetTop(this)); // Distance Vectors info.AddValue("DistanceCount" + MyID.ToString(), DistanceVector.Count); int iOther = 0; foreach (KeyValuePair <Face, double> keyValue in DistanceVector) { Face otherFace = keyValue.Key; info.AddValue("DistanceID" + MyID.ToString() + "_" + iOther.ToString(), otherFace.MyID.ToString()); info.AddValue("Distance" + MyID.ToString() + "_" + iOther.ToString(), keyValue.Value); ++iOther; } }
/// <summary> /// Deserialize the face /// </summary> /// <param name="info">Serialization info</param> /// <param name="context">Serialization context</param> /// <param name="deserializeID">Unique Id for the source</param> /// <param name="deserializeOffSet">Unique offset. Used when more than 1 face comes from the same source photo</param> public void Deserialize(SerializationInfo info, StreamingContext context, int deserializeID, int deserializeOffSet) { _pathName = info.GetString("_FacePathName" + deserializeID.ToString() + "_" + deserializeOffSet.ToString()); _photoID = info.GetInt32("_FacePhotoID" + deserializeID.ToString() + "_" + deserializeOffSet.ToString()); if (null == _parent) { _parentID = info.GetInt32("_FaceParentID" + deserializeID.ToString() + "_" + deserializeOffSet.ToString()); } else { _parentID = ((IDisplayableElement)_parent).MyID; } _parentGroupID = info.GetInt32("_FaceParentGroupID" + deserializeID.ToString() + "_" + deserializeOffSet.ToString()); _parentPhotoID = info.GetInt32("_FaceParentPhotoID" + deserializeID.ToString() + "_" + deserializeOffSet.ToString()); Canvas.SetLeft(this, info.GetDouble("FaceLeft" + deserializeID.ToString() + "_" + deserializeOffSet.ToString())); Canvas.SetTop(this, info.GetDouble("FaceTop" + deserializeID.ToString() + "_" + deserializeOffSet.ToString())); //Distances - need to temporarily desirialze into ID, value int distanceCount = info.GetInt32("DistanceCount" + MyID.ToString()); _deserializeDistance = new Dictionary <int, double>(); for (int iOther = 0; iOther < distanceCount; ++iOther) { int otherID = info.GetInt32("DistanceID" + MyID.ToString() + "_" + iOther.ToString()); double dist = info.GetDouble("Distance" + MyID.ToString() + "_" + iOther.ToString()); _deserializeDistance.Add(otherID, dist); } }
/// <summary> /// Serialization /// </summary> /// <param name="info">Serialization info</param> /// <param name="context">Serialization context</param> /// <param name="id">Unique identifier for this group. In range [0:numGroups]</param> public void GetObjectData(SerializationInfo info, StreamingContext context, int id) { info.AddValue("GroupID" + id.ToString(), MyID); info.AddValue("_GroupParentGroupID" + MyID.ToString(), _parentGroupID); info.AddValue("_GroupTagName" + MyID.ToString(), _tagTextBox.Text); info.AddValue("GroupLeft" + MyID.ToString(), Canvas.GetLeft(this)); info.AddValue("GroupTop" + MyID.ToString(), Canvas.GetTop(this)); info.AddValue("GroupDisplayState" + MyID.ToString(), (int)DisplayMode); }
/// <summary> /// Deserialization constructor for a group /// </summary> /// <param name="info">Serialization info</param> /// <param name="context">Serialization context</param> /// <param name="mainCanvas">Main canvas</param> /// <param name="id">Unique id identifying group</param> public Group(SerializationInfo info, StreamingContext context, BackgroundCanvas mainCanvas, int id) { _ID = info.GetInt32("GroupID" + id.ToString()); Initialize(mainCanvas); _parentGroupID = info.GetInt32("_GroupParentGroupID" + MyID.ToString()); _tagTextBox.Text = info.GetString("_GroupTagName" + MyID.ToString()); Canvas.SetLeft(this, info.GetDouble("GroupLeft" + MyID.ToString())); Canvas.SetTop(this, info.GetDouble("GroupTop" + MyID.ToString())); DisplayMode = (DisplayState)info.GetInt32("GroupDisplayState" + MyID.ToString()); }
public Sprite SPRITE(MyID _ID) { switch (_ID) { case MyID.MARIO_SMALL: return(MarioSmall); case MyID.MARIO_BIG: return(MarioBig); case MyID.MARIO_SUPER: return(MarioSuper); case MyID.BREAK: return(Break); case MyID.BRICK_BREAK: return(Brick_Break); case MyID.BASE: return(Base); case MyID.PIPE: return(Pipe); case MyID.QUESTION_MARK: return(Question); case MyID.COIN: return(Coin); case MyID.MUSHROOM_BIG: case MyID.MUSHROOM_1UP: return(Mushroom_Big); case MyID.MUSHROOM_TOXIC: return(Mushroom_Toxic); case MyID.TITLE: return(Title); case MyID.BRICK_HARD: return(Brick); case MyID.FLOWER: return(Flower); case MyID.BULLET: return(Bullet); case MyID.FENCE: return(fence); case MyID.POLE: return(pole); case MyID.POST: return(post); case MyID.BUILDING: return(building); case MyID.CLOUD: return(cloud); case MyID.GRASS: return(grass); case MyID.MOUNTAIN_SMALL: return(mountain_small); case MyID.MOUNTAIN_BIG: return(mountain_big); case MyID.WINPOLE: return(win_pole); case MyID.BOSS: return(Boss); case MyID.BULLETBOSS: return(BulletBoss); case MyID.BLOOD: return(Blood); case MyID.BOSS_BREAK: return(Break_Boss); } return(null); }