Dispose() 공개 메소드

回收当前对象使用的资源。
public Dispose ( ) : void
리턴 void
예제 #1
0
        /// <summary>
        /// 将指定的拼图碎片与当前的拼图碎片合并。不检查两个拼图碎片是否可以被合并。
        /// </summary>
        /// <param name="piece">要合并的拼图碎片。</param>
        public void Merge(JigsawPiece piece)
        {
            // 更新相邻拼图碎片信息。
            foreach (JigsawPiece p in piece.neighbors)
            {
                p.neighbors.Remove(piece);
                p.neighbors.Add(this);
            }
            this.neighbors.UnionWith(piece.neighbors);
            this.neighbors.Remove(this);
            // 更新形状。
            float sum = this.shape.Weight + piece.shape.Weight;

            this.offset = new Vector2((this.offset.X * this.shape.Weight + piece.offset.X * piece.shape.Weight) / sum,
                                      (offset.Y * this.shape.Weight + piece.offset.Y * piece.shape.Weight) / sum);
            this.shape.Merge(piece.shape);
            // 更新路径。
            GeometryGroup newGroup = SharpDXUtility.Merge(this.originalPath, piece.originalPath);

            this.originalPath.Dispose();
            this.originalPath = newGroup;
            this.CalculateMatrix();
            this.UpdatePath();
            if (piece.PieceType == JigsawPieceType.Border)
            {
                this.pieceType = JigsawPieceType.Border;
            }
            piece.Dispose();
        }
예제 #2
0
		/// <summary>
		/// 将指定的拼图碎片与当前的拼图碎片合并。不检查两个拼图碎片是否可以被合并。
		/// </summary>
		/// <param name="piece">要合并的拼图碎片。</param>
		public void Merge(JigsawPiece piece)
		{
			// 更新相邻拼图碎片信息。
			foreach (JigsawPiece p in piece.neighbors)
			{
				p.neighbors.Remove(piece);
				p.neighbors.Add(this);
			}
			this.neighbors.UnionWith(piece.neighbors);
			this.neighbors.Remove(this);
			// 更新形状。
			float sum = this.shape.Weight + piece.shape.Weight;
			this.offset = new Vector2((this.offset.X * this.shape.Weight + piece.offset.X * piece.shape.Weight) / sum,
				(offset.Y * this.shape.Weight + piece.offset.Y * piece.shape.Weight) / sum);
			this.shape.Merge(piece.shape);
			// 更新路径。
			GeometryGroup newGroup = SharpDXUtility.Merge(this.originalPath, piece.originalPath);
			this.originalPath.Dispose();
			this.originalPath = newGroup;
			this.CalculateMatrix();
			this.UpdatePath();
			if (piece.PieceType == JigsawPieceType.Border)
			{
				this.pieceType = JigsawPieceType.Border;
			}
			piece.Dispose();
		}