Exemplo n.º 1
0
        /// <summary>
        /// Load the picture with the given index.
        /// </summary>
        /// <param name="index">The index to use.</param>
        /// <returns>Corresponding image.</returns>
        private BitmapImage LoadPicture(Ad ad)
        {
            string directory = Directory.GetCurrentDirectory();

            string path = directory + "\\..\\..\\" + ad.filepath;
            BitmapImage value;
            try {
                Uri uri = new Uri(path);
                value = new BitmapImage(uri);
            } catch (NotSupportedException) {
                value = null;
            }

            return value;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load the picture with the given index.
        /// </summary>
        /// <param name="index">The index to use.</param>
        /// <returns>Corresponding image.</returns>
        public static BitmapImage LoadPicture(Ad ad)
        {
            if (cachedAds.ContainsKey(ad))
            {
                return cachedAds[ad];
            }
            else
            {
                string directory = Directory.GetCurrentDirectory();

                string path = directory + "\\..\\..\\" + ad.filepath;
                BitmapImage value;
                try
                {
                    Uri uri = new Uri(path);
                    value = new BitmapImage(uri);
                    cachedAds.Add(ad, value);
                }
                catch (NotSupportedException)
                {
                    value = null;
                }

                return value;
            }
        }