Click here to Skip to main content
15,895,011 members
Articles / Desktop Programming / WPF

Wrap Panel Virtualization

Rate me:
Please Sign up or sign in to vote.
4.95/5 (18 votes)
2 Jan 2012CPOL2 min read 53.7K   5.6K   41  
WrapPanel doesn't support virtualization. But we can improve the performance by simulating virtualization.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Tags
{
    /// <summary>
    /// Base object for ASF objects
    /// </summary>
    public abstract class ASFObject
    {
        private ExceptionCollection _Exceptions = new ExceptionCollection();

        /// <summary>
        /// Write current object data to specific TagStream
        /// </summary>
        /// <param name="wr">TagStream to write data to</param>
        public bool WriteData(TagStream wr)
        { return OnWritingData(wr); }

        /// <summary>
        /// Read object from specific TagStream
        /// </summary>
        /// <param name="rd">TagStream to read data from</param>
        /// <param name="ObjectSize">Maximum size of object</param>
        public bool Read(TagStream rd, long ObjectSize)
        { return OnReadingData(rd, ObjectSize); }

        /// <summary>
        /// Get GUID of current Object
        /// </summary>
        public string GUID
        {
            get
            { return OnGetGUID(); }
        }

        /// <summary>
        /// Get Length of current object
        /// </summary>
        public long Length
        {
            get
            { return OnGetLength(); }
        }

        /// <summary>
        /// Add specific exception to list of occured exceptions
        /// </summary>
        /// <param name="Ex">Exception to add</param>
        protected void AddException(Exception Ex)
        {
            _Exceptions.Add(Ex);
        }

        /// <summary>
        /// Exceptions that occured while reading this object
        /// </summary>
        public ExceptionCollection Exceptions
        {
            get
            { return _Exceptions; }
        }

        /// <summary>
        /// Call when frame need to write it's data to stream
        /// </summary>
        /// <param name="wr">TagStream to write data</param>
        protected virtual bool OnWritingData(TagStream wr)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        /// <summary>
        /// Read data from specific TagStream
        /// </summary>
        /// <param name="rd">TagStream to read data from</param>
        /// <param name="ObjectSize">Object size in tag stream</param>
        /// <returns>true if readed successfully otherwise false</returns>
        protected virtual bool OnReadingData(TagStream rd, long ObjectSize)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        /// <summary>
        /// Gets GUID of current frame 
        /// </summary>
        /// <returns></returns>
        protected virtual string OnGetGUID()
        {
            throw new Exception("The method or operation is not implemented.");
        }

         /// <summary>
        /// Gets length of current frame in byte
        /// </summary>
        /// <returns>int contain length of current frame</returns>
        protected virtual long OnGetLength()
        {
            throw new Exception("The method or operation is not implemented.");
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions