/// <summary> /// Gets the top left cell location corresponding to the given position /// </summary> /// <param name="info">Bit Information</param> /// <param name="position">Position where the user clicked w.r.t. the UIElement being dragged</param> /// <param name="positionInParent">Position where the user clicked w.r.t. the FluidWrapPanel</param> /// <returns></returns> private MatrixCell GetCellFromPoint(BitInfo info, Point position, Point positionInParent) { var row = (int)(positionInParent.Y / ItemHeight); var col = (int)(positionInParent.X / ItemWidth); // If the item is not having unit size, then calculate the top left cell location if (!info.IsUnitSize()) { row -= (int)(position.Y / ItemHeight); col -= (int)(position.X / ItemWidth); } // Bounds check if ((row < 0) || (row > _maxCellRows) || (col < 0) || (col > _maxCellCols)) { return MatrixCell.InvalidCell; } return new MatrixCell(row, col); }
/// <summary> /// Reads and parses bytes from a byte array, ensuring it's parsed correctly /// </summary> /// <typeparam name="T">Type of enum</typeparam> /// <param name="data">Byte array to read from</param> /// <param name="info">Enum value for data to read</param> /// <param name="littleEndian">Whether the data is little endian</param> /// <param name="twosComplement">Whether to parse it as a two's complement number</param> /// <returns>A parsed long</returns> protected static long ReadBytes <T>(byte[] data, T info, bool littleEndian = true, bool twosComplement = false) where T : IConvertible { BitInfo bitInfo = info.BitInfo(); return(ReadBytes(data, bitInfo.Location - 1, bitInfo.Offset, littleEndian, twosComplement)); }
public FFMpegMediaMetadataFlac(FFMpegMediaMetadata data) : base(data) { if (data is FFMpegMediaMetadataFlac) { Bit = (data as FFMpegMediaMetadataFlac).Bit; SamplingRate = (data as FFMpegMediaMetadataFlac).SamplingRate; } }