private void InitializeControls() { if (_games != null) { if (_gameCards == null) { _gameCards = new List <FoundedGameCard>(); } this.Clear(); _countItems = 0; foreach (MyAbandonGameFound game in _games) { FoundedGameCard card = new FoundedGameCard(); SetupCard(card); card.GameData = game; card.Tag = _countItems; card.IsSelected = (_countItems == 0); card.Visible = true; this.Controls.Add(card); _gameCards.Add(card); _countItems++; } //As I default the first element to be selected I need to raise the event _currentlySelected = 0; if (GameSelected != null) { GameSelected(this, _gameCards[0].GameData); } //Now checking if it is necessary to add the scrollbar if ((_gameCards.Count * 150) > this.Height) { scroller = new ScrollBarEx(); scroller.BringToFront(); scroller.Orientation = ScrollBarOrientation.Vertical; scroller.BorderColor = Color.FromArgb(64, 64, 64); scroller.Dock = DockStyle.Right; scroller.Visible = true; scroller.Maximum = (_gameCards.Count - 1) * 85; scroller.Scroll += scroller_Scroll; this.MouseWheel += cards_MouseWheel; this.Controls.Add(scroller); } else if (scroller != null) { scroller.Scroll -= scroller_Scroll; scroller.Dispose(); scroller = null; } } }
private void InitializeControls() { if (_imageURIs != null) { this.Controls.Clear(); if (_screenshots == null) { _screenshots = new List <Screenshot>(); } _screenshots.Clear(); _countItems = 0; foreach (string uri in _imageURIs) { Screenshot screenshot = new Screenshot(); SetupScreenshot(screenshot); screenshot.LoadScreenshot(uri); screenshot.IsSelected = (_countItems == 0); screenshot.Tag = _countItems; this.Controls.Add(screenshot); _screenshots.Add(screenshot); _countItems++; } //As defaulting to select the first element I also raise selection event after first init _currentlySelected = 0; if (ScreenshotSelected != null) { ScreenshotSelected(this, _screenshots[0].ScreenshotImage); } //Now checking if it is necessary to add the scrollbar if ((_screenshots.Count * 150) > this.Height) { scroller = new ScrollBarEx(); scroller.BringToFront(); scroller.Orientation = ScrollBarOrientation.Vertical; scroller.BorderColor = Color.FromArgb(64, 64, 64); scroller.Dock = DockStyle.Right; scroller.Visible = true; scroller.Maximum = (_screenshots.Count - 1) * 150; scroller.Scroll += scroller_Scroll; this.MouseWheel += screenshot_MouseWheel; this.Controls.Add(scroller); } else if (scroller != null) { scroller.Scroll -= scroller_Scroll; scroller.Dispose(); scroller = null; } } }