public SteamAddView()
        {
            InitializeComponent();

            listViewGames.ItemSelectionChanged += (sender, e) => {
                if (!e.IsSelected)
                    return;

                var gameItem = e.Item as GameListViewItem;

                if (gameItem == null)
                    return;

                if (GameSelected != null)
                    GameSelected (this, new GameEventArgs (gameItem.Game));

                model = gameItem.Game;
            };

            listBoxDirectories.SelectedValueChanged += (sender, e) => {
                if( listBoxDirectories.SelectedIndex < 0 ) {
                    return;
                }

                if(DirectorySelected == null) {
                    return;
                }

                DirectorySelected( this, new FileSystemEventArgs(WatcherChangeTypes.All, listBoxDirectories.SelectedItem.ToString(), ""));
            };

            buttonClose.Click += (sender, e) => Close ();

            buttonAdd.Click += (sender, e) =>
            {
                if( AddGame != null )
                    AddGame( this, new GameEventArgs(model));
            };

            buttonBrowse.Click += (sender, e) => {

                folderBrowserDialog.Description = string.Format ("Browse for the installation folder for {0}", model.Name);
                folderBrowserDialog.ShowNewFolderButton = false;

                var dialogResult = folderBrowserDialog.ShowDialog ();

                if (dialogResult != DialogResult.OK)
                    return;

                textBoxCustomFolder.Text = folderBrowserDialog.SelectedPath;

                if (DirectorySelected != null)
                    DirectorySelected (this, new FileSystemEventArgs (WatcherChangeTypes.All, folderBrowserDialog.SelectedPath, ""));
            };
        }
 public GameEventArgs(Game game)
 {
     Game = game;
 }
 public GameListViewItem(Game game)
     : base(game.Name)
 {
     Game = game;
     ImageKey = game.externalId;
 }
        GameListViewItem CreateListViewItem(Game game)
        {
            try
            {
                var image = Image.FromStream (System.Net.WebRequest.Create (game.boxart).GetResponse ().GetResponseStream ());
                imageListSteam.Images.Add (game.externalId, image);
            }
            catch
            {
                imageListSteam.Images.Add (game.externalId, SystemIcons.Application);
            }

            return new GameListViewItem (game);
        }
        public void RemoveGame( Game game )
        {
            var viewGame = listViewGames.Items.Cast<GameListViewItem> ().FirstOrDefault (x => x.Game.externalId == game.externalId);

            if (viewGame == null)
                return;

            // Remove the game from the list view
            listViewGames.Items.Remove (viewGame);

            // Clear the directories list
            SetSuggestedDirectories (new List<DirectoryInfo> ());

            if (model == game)
                model = null;
        }
        public void AddGameToList(Game game)
        {
            var item = CreateListViewItem (game);

            listViewGames.Items.Add (item);
        }