Exemple #1
0
        public frmMain()
        {
            InitializeComponent();
            // inform user of update availability if needed.
            llUpdate.Visible = !Program.updateToDate();

            // Maxmise window.
            this.WindowState = FormWindowState.Maximized;

            // Code Below sets up action listeners for Control interactions

            // Setup the listener for controller input
            controllerInput.ButtonPressed += Ci_ButtonPressed;

            // Sets playing to true and lanches the selected game. Waits for close and then sets playing to false.
            btnPlay.Click += (sender, e) =>
            {
                if (lbGames.SelectedIndex >= 0 && lbGames.SelectedIndex < lbGames.Items.Count)
                {
                    int sel = lbGames.SelectedIndices[0]; var p = cbPlatform.SelectedItem; playing = true;
                    DataManagement.Games.Find(x => x.getFriendlyName() == (string)lbGames.SelectedItem).launch();
                    reload(); lbGames.SelectedIndex = sel; cbPlatform.SelectedItem = p; playing = false;
                    playing = false;
                }
            };

            bulkFromDirectoryToolStripMenuItem.Click += BulkFromDirectoryToolStripMenuItem_Click;
            // Action Listener for the bulk rom import option
            fromFileToolStripMenuItem.Click += (sender, e) =>
            {
                var dia = new frmAddGameDia();
                // Get the data for ROM Import from the add game dialog.
                if (dia.ShowDialog() == DialogResult.OK)
                    DataManagement.Games.Add(new Game(dia.results));
                // Reload the UI to reflect changes.
                reload();
            };

            // Code to open the platform manager when the appropriate button is clicked (File -> Manage Platforms)
            managePlatformsToolStripMenuItem.Click += (sender, e) => {
                frmPlatManager fp = new frmPlatManager();
                fp.ShowDialog();  reload(); };

            // Code which changes the games shown based on filter and search settings
            Action FilterChange = () => {
                filterBy(DataManagement.Platforms.Find(x => x.getFriendlyName() == cbPlatform.Text),
                    DataManagement.Games.FindAll(x => x.getFriendlyName().ToLower().Contains(tbSearch.Text.ToLower())));
            };

            // Calls the FilterChange code when required.
            cbPlatform.SelectedIndexChanged += (sender, e) => { FilterChange(); };
            tbSearch.TextChanged += (sender, e) => { FilterChange(); };

            // Updates all UI Elements
            reload();
        }
 private static bool platformsCheck()
 {
     if (!File.Exists(platInfoDir))
     {
         MessageBox.Show("No Platforms found.\nPlatform must be created to proceed.");
         frmPlatManager addP = new frmPlatManager();
         addP.ShowDialog();
         if (Platforms.Count == 0)
             return false;
     }
     return true;
 }