Source

FaviconBrowser / FaviconBrowser / MainWindow.xaml.cs

alexdavies74 16db66b 

alexdavies74 220e6a2 

alexdavies74 8a405f1 










alexdavies74 08f5e70 













alexdavies74 8a405f1 



alexdavies74 220e6a2 


alexdavies74 95d3fcd 
alexdavies74 220e6a2 

alexdavies74 95d3fcd 
alexdavies74 220e6a2 

alexdavies74 95d3fcd 



alexdavies74 16db66b 
alexdavies74 95d3fcd 





alexdavies74 9e01f8b 



alexdavies74 220e6a2 







alexdavies74 9e01f8b 
alexdavies74 220e6a2 
alexdavies74 8a405f1 
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

namespace FaviconBrowser
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private static readonly List<string> s_Domains = new List<string>
                                                             {
                                                                 "google.com",
                                                                 "bing.com",
                                                                 "oreilly.com",
                                                                 "simple-talk.com",
                                                                 "microsoft.com",
                                                                 "facebook.com",
                                                                 "twitter.com",
                                                                 "reddit.com",
                                                                 "baidu.com",
                                                                 "bbc.co.uk"
                                                             };

        public MainWindow()
        {
            InitializeComponent();
        }

        private void GetButton_OnClick(object sender, RoutedEventArgs e)
        {
            AddRemainingFavicons(s_Domains, 0);
        }

        private void AddRemainingFavicons(List<string> domains, int i)
        {
            WebClient webClient = new WebClient();
            webClient.DownloadDataCompleted += (o, args) =>
                {
                    Image imageControl = MakeImageControl(args.Result);
                    m_WrapPanel.Children.Add(imageControl);

                    if (i + 1 < domains.Count)
                    {
                        AddRemainingFavicons(domains, i + 1);
                    }
                };
            webClient.DownloadDataAsync(new Uri("http://" + domains[i] + "/favicon.ico"));
        }

        private static Image MakeImageControl(byte[] bytes)
        {
            Image imageControl = new Image();
            BitmapImage bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.StreamSource = new MemoryStream(bytes);
            bitmapImage.EndInit();
            imageControl.Source = bitmapImage;
            imageControl.Width = 16;
            imageControl.Height = 16;
            return imageControl;
        }
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.