private void binaryMapViewer1_BinSelect(object sender, Bin bin)
        {
            if (bin.Tag == null)
                lvExif.SelectedItems.Clear();

            foreach (ListViewItem item in lvExif.Items)
            {
                if (item.Tag == bin.Tag)
                {
                    item.Selected = true;
                    lvExif.EnsureVisible(lvExif.Items.IndexOf(item));
                    return;
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Reads the next bin in the stream.
        /// </summary>
        public Bin Read()
        {
            // Find and return the bin
            foreach (KeyValuePair<long, Bin> obj in list)
            {
                if (mPosition >= obj.Key && mPosition < obj.Key + obj.Value.Length)
                {
                    long offset = obj.Key;
                    mPosition = offset + obj.Value.Length;
                    return obj.Value;
                }
            }

            // Return a null bin
            long start = 0;
            foreach (KeyValuePair<long, Bin> obj in list)
            {
                if (obj.Key + obj.Value.Length <= mPosition)
                {
                    start = obj.Key + obj.Value.Length;
                }
            }
            long end = 0;
            foreach (KeyValuePair<long, Bin> obj in list)
            {
                if (obj.Key > mPosition)
                {
                    end = obj.Key;
                    break;
                }
            }
            mPosition = start;
            Bin bin = new Bin("Null", 0, end - start);
            bin.Offset = mPosition;
            mPosition += bin.Length;
            return bin;
        }
Exemple #3
0
 /// <summary>
 /// Writes a bin to the current position.
 /// </summary>
 public void Write(Bin bin)
 {
     foreach (KeyValuePair<long, Bin> obj in list)
     {
         if ((mPosition >= obj.Key) && (mPosition < obj.Key + obj.Value.Length))
             throw new Exception("Cannot overwrite stream.");
     }
     bin.Offset = mPosition;
     list.Add(mPosition, bin);
     mPosition += bin.Length;
 }
Exemple #4
0
 /// <summary>
 /// Selects the specified bin.
 /// </summary>
 public void SelectBin(Bin bin)
 {
     long offset = mMap.Position;
     mMap.Seek(0, System.IO.SeekOrigin.Begin);
     while (!mMap.EOF)
     {
         Bin s = mMap.Read();
         if (s.GetHashCode() == bin.GetHashCode())
         {
             mMap.Seek(s.Offset, System.IO.SeekOrigin.Begin);
             selectedbin = s.GetHashCode();
             Refresh();
             return;
         }
     }
     mMap.Seek(offset, System.IO.SeekOrigin.Begin);
     return;
 }