Beispiel #1
0
        /// <summary>
        /// Clean up.
        /// </summary>
        public void Dispose()
        {
            // unsubscribe from events
            Framework.Instance.DeviceCreated -= new Bonsai.Core.EventArgs.DeviceEventHandler(Instance_DeviceCreated);
            Framework.Instance.DeviceLost    -= new EventHandler(Instance_DeviceLost);
            Framework.Instance.DeviceReset   -= new Bonsai.Core.EventArgs.DeviceEventHandler(Instance_DeviceReset);

            if ((fileName != null) && (_textures.ContainsKey(fileName)))
            {
                GlobalTexture globalTexture = _textures[fileName];
                globalTexture.ReferenceCount--;
                if (globalTexture.ReferenceCount == 0)
                {
                    globalTexture.BaseTexture.Dispose();
                    globalTexture.BaseTexture = null;
                    _textures.Remove(fileName);
                }
                else
                {
                    _textures[fileName] = globalTexture;
                }
            }
            else
            {
                if (texture != null)
                {
                    texture.Dispose();
                    texture = null;
                }
            }
        }