示例#1
0
 public CategoryGames(AppManager manager)
     : base(manager)
 {
     InitializeComponent();
     _previousGameID = -1;
     scroller = null;
 }
示例#2
0
 public CategoryGames(AppManager manager, List<Game> games, Dictionary<String, Category> cats)
     : base(manager, games, cats)
 {
     InitializeComponent();
     _previousGameID = -1;
     scroller = null;
     UpdateUI();
 }
示例#3
0
        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;
                }
            }
        }
示例#4
0
        public override void UpdateUI()
        {
            Controls.Clear();
            int maxRenderableColumns = (Width - 20) / 180;
            int maxRenderableRows = Height / 160;
            int rowsCount = 0;
            int columnsCount = 0;
            if (_games == null || _games.Count <= 0)
                return;
            int currentLeft = 0;
            foreach (Game game in _games)
            {
                GameBox gameBox = new GameBox(_settings.BoxRendered);
                gameBox.BoxSelected += new GameBox.BoxSelectedDelegate(Box_BoxSelected);
                gameBox.BoxDoubleClick += new GameBox.BoxDoubleClickDelegate(Box_BoxDoubleClick);
                gameBox.ContextMenuStrip = CreateGameContextMenu(game.ID);
                gameBox.GameName = game.Title;

                if (File.Exists(game.ImagePath))
                    gameBox.GameImage = Image.FromFile(game.ImagePath);
                else
                    gameBox.GameImage = null;

                gameBox.GameID = game.ID;
                gameBox.Top = rowsCount * 160 + (rowsCount == 0 ? 0 : 5);
                gameBox.Left = currentLeft;
                currentLeft += gameBox.Width;
                this.Controls.Add(gameBox);
                ++columnsCount;
                if (columnsCount >= maxRenderableColumns)
                {
                    columnsCount = 0;
                    ++rowsCount;
                    currentLeft = 0;
                }
            }
            if (rowsCount + 1 > maxRenderableRows)
            {
                scroller = new ScrollBarEx();
                scroller.Orientation = ScrollBarOrientation.Vertical;
                scroller.BorderColor = Color.FromArgb(64, 64, 64);
                scroller.Dock = DockStyle.Right;
                scroller.Visible = true;
                scroller.Maximum = (rowsCount + 1) * 160;
                scroller.Scroll += scroller_Scroll;
                this.MouseWheel += CategoryGames_MouseWheel;
                this.Controls.Add(scroller);
            }
            else if (scroller != null)
            {
                scroller.Scroll -= scroller_Scroll;
                scroller.Dispose();
                scroller = null;
            }
            this.Focus();
        }
示例#5
0
        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;
                }
            }
        }