Ejemplo n.º 1
0
        /// <summary>
        /// Gets a string containing the selected entries.
        /// </summary>
        /// <returns>A string containing the selected entries.</returns>
        private string SelectedEntriesString()
        {
            //	Instantiate the text and html string builders.
            StringBuilder stringBuilder = new StringBuilder();

            //	Prevent updates while we work.
            lock (this)
            {
                //	Obtain the selected list.
                ListView.SelectedListViewItemCollection selectedListViewItemCollection = listViewLog.SelectedItems;

                //	If there are entries selected, copy them to the clipboard.
                if (selectedListViewItemCollection != null && selectedListViewItemCollection.Count != 0)
                {
                    //	Build the strings to be copied to the clipboard.
                    foreach (ListViewItem listViewItem in selectedListViewItemCollection)
                    {
                        //	Append an extra line in between entries.
                        if (stringBuilder.Length != 0)
                        {
                            stringBuilder.Append("\r\n");
                        }

                        //	Access the BufferingTraceListenerEntry tagged to the entry.
                        BufferingTraceListenerEntry bufferingTraceListenerEntry = (BufferingTraceListenerEntry)listViewItem.Tag;

                        //	Build the text line for the entry.
                        stringBuilder.AppendFormat("{0}\r\n", bufferingTraceListenerEntry.ToString());
                    }
                }
            }

            //	Done.
            return(stringBuilder.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets an array of BufferingTraceListenerEntry objects starting at the specified index.
        /// </summary>
        /// <param name="index">The index at which to return BufferingTraceListenerEntry objects.  This value is updated.</param>
        /// <returns>An array of BufferingTraceListenerEntry objects, or null.</returns>
        public BufferingTraceListenerEntry[] GetEntries(ref int index)
        {
            //	Return what was asked for.
            lock (this)
            {
                //	Validate startIndex.
                if (index < 0 || index > entryList.Count)
                {
                    throw new ArgumentOutOfRangeException("index", index, "Index out of range.");
                }

                //	If there are no new entries to return, return null.
                if (index != entryList.Count)
                {
                    int returnCount = entryList.Count - index;
                    BufferingTraceListenerEntry[] bufferingTraceListenerEntryArray = new BufferingTraceListenerEntry[returnCount];
                    entryList.CopyTo(index, bufferingTraceListenerEntryArray, 0, returnCount);
                    index = entryList.Count;
                    return(bufferingTraceListenerEntryArray);
                }
            }

            //	Done.
            return(new BufferingTraceListenerEntry[0]);
        }
        /// <summary>
        /// Gets an array of BufferingTraceListenerEntry objects starting at the specified index.
        /// </summary>
        /// <param name="index">The index at which to return BufferingTraceListenerEntry obejcts.  This value is updated.</param>
        /// <returns>An array of BufferingTraceListenerEntry objects, or null.</returns>
        public BufferingTraceListenerEntry[] GetEntries(ref int index)
        {
            //	Return what was asked for.
            lock (this)
            {
                //	Validate startIndex.
                if (index < 0 || index > entryList.Count)
                    throw new ArgumentOutOfRangeException("index", index, "Index out of range.");

                //	If there are no new entries to return, return null.
                if (index != entryList.Count)
                {
                    int returnCount = entryList.Count - index;
                    BufferingTraceListenerEntry[] bufferingTraceListenerEntryArray = new BufferingTraceListenerEntry[returnCount];
                    entryList.CopyTo(index, bufferingTraceListenerEntryArray, 0, returnCount);
                    index = entryList.Count;
                    return bufferingTraceListenerEntryArray;
                }
            }

            //	Done.
            return new BufferingTraceListenerEntry[0];
        }