Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Wrap Panel Virtualization

, 2 Jan 2012
WrapPanel doesn't support virtualization. But we can improve the performance by simulating virtualization.
MediaAssistant_bin.zip
MediaAssistant_src
DokanNet.dll
Id3Lib.dll
Media Assistant.exe
Media Assistant.exe.manifest
MediaAssistant.DAL.dll
MediaFS.dll
MefBasic.dll
Microsoft.Practices.Composite.dll
Microsoft.Practices.Composite.MefExtensions.dll
Microsoft.Practices.Composite.Presentation.dll
Microsoft.Practices.ServiceLocation.dll
Mp3Lib.dll
Newtonsoft.Json.Net35.dll
SharpZipLib.dll
Tags.dll
MediaAssistant_src.zip
DokanNet
Properties
Lib
CommonServiceLocation
Desktop
Microsoft.Practices.ServiceLocation.dll
CompositeApplicationLibrary
Desktop
Microsoft.Practices.Composite.dll
Microsoft.Practices.Composite.MefExtensions.dll
Microsoft.Practices.Composite.Presentation.dll
Dokan
dokan.lib
Moq
Desktop
Moq.dll
Mp3Lib
Id3Lib.dll
Mp3Lib.dll
SharpZipLib.dll
Newtonsoft
Newtonsoft.Json.Net35.dll
NUnit
nunit.framework.dll
MediaAssistant
MediaAssistant.csproj.user
MediaAssistant.ico
MusicAssistant_TemporaryKey.pfx
Constants
Controls
About
AddMovie
AlternativeLocation
BottomPanel
Dialog
LeftPanel
Library
MessageBox
MovieDetail
MovieList
MovieMiddlePanel
MovieResult
MovieSearchControl
MovieThumbnails
MusicList
MusicMiddlePanel
MusicSearchControl
PlayerControl
PlayingMusicInfo
PlaylistSelector
ProfileSelector
SendFeedback
SmartDJPreferance
SplashScreen
SplashPage.png
StatusMessageBar
TagEditor
TopPanel
WaitScreen
Converters
Data
EventArguments
HeaderImages
Close_act.png
Close_inact.png
Close_pr.png
Maximize_act.png
Maximize_inact.png
Maximize_pr.png
Minimize_act.png
Minimize_inact.png
Minimize_pr.png
Helper
Images
AcceptFolder.png
Actor.png
ActorLibrary.png
AddFolder.png
Album.png
Artist.png
Close.png
Composer.png
Default.png
DeleteFolder.png
Director.png
DrivesMovies.png
eye16.png
FailedToPlayMusic.png
Genre.png
IMDB.png
Library.png
ListView.png
Logo.png
Maximize.png
Menu.png
Mount.png
MovieBackground.jpg
MovieBackground.png
MovieFolder.png
MovieGenre.png
MovieLibrary.png
MoviePoster.png
Music.png
MusicAssistant.png
MusicLibrary.png
Mute.png
New.png
NewMovies.png
NoDJ.png
NonPlayingMusic.png
NormalShuffle.png
NoShuffle.png
NowPlayingMusic.png
PlayingMusic.png
playlist.png
PlayMovie.png
ProcessDone.png
ProcessFailed.png
Processing.png
Rated.png
Recent.png
RecommendedMovie.png
Restore.png
Runtime.png
SmartShuffle.png
Song.png
Star.png
Swap.png
ThumbnailView.png
Tools.png
TreeCollapse.png
TreeExpand.png
Unread.png
Volume.png
WatchList.png
WishList.png
Writer.png
Year.png
Management
MusicDJ
Properties
Settings.settings
Resources
MediaAssistant.DAL
MediaAssistant.sdf
MediaAssistantModels.edmx
Constants
DBUpdateScript
Helper
Properties
Settings.settings
DataSources
MusicAssistantEntities.datasource
TasteKidEntities.datasource
Virtualization
MediaAssistant.Setup
MusicAssistant.Setup.vdproj
MediaFS
DokanInstall_0.6.0.exe
Properties
MefBasic
Behaviors
Commans
Controls
Converters
Data
Extensions
Helper
Properties
Settings.settings
Themes
Threading
UserControls
Properties
TagClass
ASF Classes
Frames Classes
ID3
Properties
Text Files
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MefBasic.Data
{
    [Serializable]
    public class ChangedDataCollection
    {
        public ChangedDataCollection()
        {
            Items=new Dictionary<string, List<object>>();
        }
        public Dictionary<string, List<object>> Items { get; set; }

        public void Add<T>(T data)
        {
            Add(data, typeof(T).ToString());
        }

        public void Add(object data, string key)
        {
            var collection = GetDataCollection(key);
            if (collection.Contains(data) == false)
                collection.Add(data);
        }

        private List<object> GetDataCollection(string key)
        {
            List<object> dataCollection;
            if(Items.ContainsKey(key))
            {
                dataCollection = Items[key];
            }
            else
            {
                dataCollection=new List<object>();
                Items.Add(key,dataCollection);
            }
            return dataCollection;
        }

        public T GetObject<T>()
        {
            return (T) GetObject(typeof (T).ToString());
        }

        public T[] GetObjects<T>()
        {
            var key = typeof(T).ToString();
            return GetObjects<T>(key);
        }

        public T[] GetObjects<T>(string key)
        {
            var objs = GetDataCollection(key).ToArray();
            var objects=new List<T>();
            foreach (var o in objs)
            {
                objects.Add((T) o);
            }
            return objects.ToArray();
        }
        public T[] OfType<T>()
        {
            var items = new List<T>();
            foreach (var list in Items.Values)
            {
                items.AddRange(list.OfType<T>());
            }
            return items.ToArray();
        }

        public object GetObject(string key)
        {
            return GetDataCollection(key).SingleOrDefault();
        }

        public void AddRange<T>(IEnumerable list)
        {
            foreach (T item in list)
            {
                Add(item);
            }
        }

        public void Remove<T>(T data)
        {
            GetDataCollection(typeof (T).ToString()).Remove(data);
        }

        public void Clear()
        {
            Items.Clear();
        }
        public bool Contains<T>(T data)
        {
            var collection = GetDataCollection(typeof(T).ToString());
            return collection.Contains(data);
        }

        public T GetObject<T>(string key)
        {
            var value = GetObject(key);
            if (value == null)
                return default(T);
            return (T)value;
        }

        public bool ContainsKey<T>()
        {
            return ContainsKey(typeof(T).ToString());
        }
        public bool ContainsKey(string key)
        {
            return Items.ContainsKey(key);
        }

        public bool Contains<T>()
        {
            return GetDataCollection(typeof (T).ToString()).Count > 0;
        }

        public void Remove<T>()
        {
            GetDataCollection(typeof (T).ToString()).Clear();
        }
    }
}

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)

Share

About the Author

H. S. Masud
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 2 Jan 2012
Article Copyright 2012 by H. S. Masud
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid