コード例 #1
0
ファイル: Slideshow.cs プロジェクト: jkiske/Senior-Design
        /// <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;
        }
コード例 #2
0
ファイル: AdView.xaml.cs プロジェクト: jkiske/Senior-Design
        /// <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;
            }
        }