예제 #1
0
        /// <summary>
        /// Saves a AnnotationGroupCollection to a byte array.
        /// </summary>
        /// <param name="rg">Specifies the list of AnnotationGroup to save.</param>
        /// <param name="bIncludeLabels">Optionally, include the labels.</param>
        /// <returns>The byte array is returned.</returns>
        public static byte[] ToByteArray(AnnotationGroupCollection rg, bool bIncludeLabels = false)
        {
            using (MemoryStream ms = new MemoryStream())
                using (BinaryWriter bw = new BinaryWriter(ms))
                {
                    SaveList(bw, rg);

                    bw.Write(bIncludeLabels);
                    if (bIncludeLabels)
                    {
                        SaveLabels(bw, rg);
                    }

                    bw.Write(rg.ImageID);
                    bw.Write(rg.ImageIdx);
                    bw.Write(rg.CreatorID);
                    bw.Write(rg.DatasetID);
                    bw.Write(rg.SourceID);
                    bw.Write(rg.HasDataCriteria);
                    bw.Write(rg.HasDebugData);

                    ms.Flush();
                    return(ms.ToArray());
                }
        }
예제 #2
0
 /// <summary>
 /// Add another AnnotationGroupCollection to this one.
 /// </summary>
 /// <param name="col">Specifies the annotation group to add.</param>
 public void Add(AnnotationGroupCollection col)
 {
     foreach (AnnotationGroup g in col)
     {
         m_rgItems.Add(g);
     }
 }
예제 #3
0
 /// <summary>
 /// Save the labels to a binary writer.
 /// </summary>
 /// <param name="bw">Specifies the binary writer.</param>
 /// <param name="rg">Specifies the AnnotationGroupCollection to save.</param>
 public static void SaveLabels(BinaryWriter bw, AnnotationGroupCollection rg)
 {
     bw.Write(rg.Labels.Count);
     foreach (KeyValuePair <int, string> kv in rg.Labels)
     {
         bw.Write(kv.Key);
         bw.Write(kv.Value);
     }
 }
예제 #4
0
        /// <summary>
        /// Save an AnnotationGroupCollection to a binary writer.
        /// </summary>
        /// <param name="bw">Specifies the binary writer.</param>
        /// <param name="rg">Specifies the AnnotationGroupCollection to save.</param>
        public static void SaveList(BinaryWriter bw, AnnotationGroupCollection rg)
        {
            bw.Write(rg.Count);

            foreach (AnnotationGroup g in rg)
            {
                g.Save(bw);
            }

            bw.Write(rg.ImageID);
            bw.Write(rg.ImageIdx);
            bw.Write(rg.CreatorID);
            bw.Write(rg.DatasetID);
            bw.Write(rg.SourceID);
            bw.Write(rg.HasDataCriteria);
            bw.Write(rg.HasDebugData);
        }
예제 #5
0
        /// <summary>
        /// Load an AnnotationGroupCollection from a binary stream.
        /// </summary>
        /// <param name="br">Specifies the binary reader.</param>
        /// <returns>The list of annotation groups is returned.</returns>
        public static AnnotationGroupCollection LoadList(BinaryReader br)
        {
            AnnotationGroupCollection rg = new AnnotationGroupCollection();
            int nCount = br.ReadInt32();

            for (int i = 0; i < nCount; i++)
            {
                rg.Add(AnnotationGroup.Load(br));
            }

            rg.ImageID         = br.ReadInt32();
            rg.ImageIdx        = br.ReadInt32();
            rg.CreatorID       = br.ReadInt32();
            rg.DatasetID       = br.ReadInt32();
            rg.SourceID        = br.ReadInt32();
            rg.HasDataCriteria = br.ReadBoolean();
            rg.HasDebugData    = br.ReadBoolean();

            return(rg);
        }
예제 #6
0
        /// <summary>
        /// Returns an AnnotationGroupCollection from a byte array.
        /// </summary>
        /// <param name="rg">Specifies the byte array to load.</param>
        /// <returns>The list of annotation groups is returned.</returns>
        public static AnnotationGroupCollection FromByteArray(byte[] rg)
        {
            using (MemoryStream ms = new MemoryStream(rg))
                using (BinaryReader br = new BinaryReader(ms))
                {
                    AnnotationGroupCollection col = LoadList(br);

                    if (br.ReadBoolean())
                    {
                        col.Labels = LoadLabels(br);
                    }

                    col.ImageID         = br.ReadInt32();
                    col.ImageIdx        = br.ReadInt32();
                    col.CreatorID       = br.ReadInt32();
                    col.DatasetID       = br.ReadInt32();
                    col.SourceID        = br.ReadInt32();
                    col.HasDataCriteria = br.ReadBoolean();
                    col.HasDebugData    = br.ReadBoolean();

                    return(col);
                }
        }
예제 #7
0
        /// <summary>
        /// Return a copy of the collection.
        /// </summary>
        /// <returns>A copy of the collection is returned.</returns>
        public AnnotationGroupCollection Clone()
        {
            AnnotationGroupCollection col = new AnnotationGroupCollection();

            foreach (AnnotationGroup g in m_rgItems)
            {
                col.Add(g.Clone());
            }

            foreach (KeyValuePair <int, string> kv in m_rgLabels)
            {
                col.m_rgLabels.Add(kv.Key, kv.Value);
            }

            col.ImageID         = m_nImageID;
            col.ImageIdx        = m_nImageIdx;
            col.CreatorID       = m_nCreatorID;
            col.DatasetID       = m_nDatasetID;
            col.SourceID        = m_nSourceID;
            col.HasDataCriteria = m_bHasDataCriteria;
            col.HasDebugData    = m_bHasDebugData;

            return(col);
        }