예제 #1
0
        /// <summary>
        /// Récupérer une image resource
        /// </summary>
        /// <param name="url">Url de l'image</param>
        /// <returns>Image</returns>
        public static Texture2D GetPermanentMenu(int width, int height, ViewerEnums.MenuType type)
        {
            //Dictionnaire d'image
            if (_PermanentResources == null)
            {
                _PermanentResources = new Dictionary <string, Texture2D>();
            }

            string serial = "MENU|" + VO_GUI.RefResource + ";" + width + ";" + height + ";" + type.ToString();

            //Création et ajout de l'image si non présente dans le dictionnaire
            if (!_PermanentResources.ContainsKey(serial))
            {
                CreateMenu(width, height, type);
            }

            //Renvoie de l'image
            try
            {
                return(_PermanentResources[serial]);
            }
            catch (Exception e)
            {
                LogTools.WriteInfo(string.Format(Logs.MANAGER_IMAGE_KEY_NOT_FOUND, serial));
                LogTools.WriteDebug(e.Message);
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// Crée une image de menu
        /// </summary>
        /// <param name="width">Largeur du menu</param>
        /// <param name="height">Hauteur du menu</param>
        /// <param name="type">Type de menu (back ou front)</param>
        public static void CreateMenu(int width, int height, ViewerEnums.MenuType type)
        {
            //Dictionnaire d'image
            if (_PermanentResources == null)
            {
                _PermanentResources = new Dictionary <string, Texture2D>();
            }

            string serial = "MENU|" + VO_GUI.RefResource + ";" + width + ";" + height + ";" + type.ToString();

            //Ajout de l'image
            if (!_PermanentResources.ContainsKey(serial))
            {
                try
                {
                    switch (type)
                    {
                    case ViewerEnums.MenuType.Back:
                        _PermanentResources.Add(serial, CreateMenuBack(width, height));
                        break;

                    case ViewerEnums.MenuType.Front:
                        _PermanentResources.Add(serial, CreateMenuFront(width, height));
                        break;
                    }

                    LogTools.WriteDebug(string.Format(Logs.MANAGER_IMAGE_CREATED, serial, Logs.MANAGER_PERMANENT));
                }
                catch (InsufficientMemoryException ie)
                {
                    LogTools.WriteInfo(Logs.MANAGER_MEMORY_ERROR);
                    LogTools.WriteDebug(ie.Message);
                    FreePermanentImages();
                    CreateMenu(width, height, type);
                }
                catch (Exception e)
                {
                    LogTools.WriteInfo(string.Format(Logs.MANAGER_IMAGE_NOT_FOUND, serial));
                    LogTools.WriteDebug(e.Message);
                    _PermanentResources.Add(serial, null);
                }
            }
        }