Exemple #1
0
        public virtual void CloseView()
        {
            foreach (TimerInfo timerInfo in _TimerList)
            {
                timerInfo._Timer.Enabled = false;
            }

            _TimerList.Clear();

            foreach (GameControls.XLBE.Sound_Instance playingSound in _AudioPlayList)
            {
                playingSound.release();
            }

            _AudioPlayList.Clear();

            int k = 0;

            Type type = GetType();

            FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            for (int i = 0; i < fields.Length; i++)
            {
                FieldInfo fieldInfo = fields[i];

                switch (fieldInfo.FieldType.Name)
                {
                case "Image":
                {
                    Bitmap bitmap = (Bitmap)fieldInfo.GetValue(this);

                    if (bitmap != null)
                    {
                        bitmap.Dispose();
                    }
                }
                break;

                case "CPngImage":
                {
                    CPngImage pngImage = (CPngImage)fieldInfo.GetValue(this);
                    pngImage.Dispose();
                }
                break;

                case "CPngImage[]":
                {
                    CPngImage[] pngImageList = (CPngImage[])fieldInfo.GetValue(this);

                    foreach (CPngImage pngImage in pngImageList)
                    {
                        pngImage.Dispose();
                    }
                }
                break;

                case "PictureButton":
                {
                    PictureButton pictureButton = (PictureButton)fieldInfo.GetValue(this);

                    if (pictureButton != null)
                    {
                        pictureButton.Dispose();
                    }
                }
                break;

                case "CSkinButton":
                {
                    CSkinButton skinButton = (CSkinButton)fieldInfo.GetValue(this);

                    if (skinButton != null)
                    {
                        skinButton.Dispose();
                    }
                }
                break;

                case "CMyD3DTexture":
                {
                    CMyD3DTexture d3dTexture = (CMyD3DTexture)fieldInfo.GetValue(this);
                    d3dTexture.Dispose();
                }
                break;

                case "CMyD3DTexture[]":
                {
                    CMyD3DTexture[] d3dTextureList = (CMyD3DTexture[])fieldInfo.GetValue(this);

                    foreach (CMyD3DTexture d3dTexture in d3dTextureList)
                    {
                        d3dTexture.Dispose();
                    }
                }
                break;
                }
            }
        }