Пример #1
0
        private void addNewGameButton_Click(object sender, EventArgs e)
        {
            // Get the user input
            string path = newGamePathTextBox.Text;
            string name = newGameName.Text;

            if (string.IsNullOrWhiteSpace(name))
            {
                return;
            }

            // Make sure the user is not adding a game already in the list
            if (Games.Any(g => g.Name.Equals(name, StringComparison.OrdinalIgnoreCase) || g.Path.Equals(path)))
            {
                MessageBox.Show("This game has already been added to the library");
                return;
            }

            IOChecker     checker = new IOChecker();
            DirectoryInfo result  = checker.ShouldUseDir(path);

            if (result == null)
            {
                return;
            }

            GameAdder adder = new GameAdder();

            adder.DataReady += AdderOnDataReady;
            adder.AddGame(result, name);
            newGamePathTextBox.Text = "";
            newGameName.Text        = "";
        }
Пример #2
0
        // Gets the organized categories from the last method and applies those to the UI, updating it.
        // Generates a Card for each different category and then makes +1 to them until the array is done.
        // Then inserts the card into the UI.
        public void FilterUI(List <Configuracion> games)
        {
            WrapPanel.Children.Clear();

            GameAdder gA = new GameAdder();

            foreach (var game in games)
            {
                string nombre = game.juego.nombre.Replace('\\', '_').Replace('/', '_').Replace(':', '_').Replace('*', '_').Replace('?', '_').Replace('\"', '_').Replace('<', '_').Replace('>', '_').Replace('|', '_').Replace(' ', '_');

                GameCard gC = new GameCard
                {
                    Tag = nombre
                };
                if (game.favorito == 1)
                {
                    gC.FavButton.Style = null;
                }
                gC.FavButton.Tag           = nombre;
                gC.PlayButton.MouseUp     += gA.PlayButtonPressed;
                gC.FavButton.MouseUp      += gA.FavButtonPressed;
                gC.SettingsButton.MouseUp += gA.SettingsButtonPressed;
                gC.GameName.MouseUp       += gA.GameNamePressed;
                gC.ImageGame.ImageSource   = new BitmapImage(new Uri(game.juego.imageUrl));
                gC.GameName.Text           = game.juego.nombre;
                gC.GameName.Tag            = nombre;
                gC.PlayButton.Tag          = game.pathExe;
                gC.SettingsButton.Tag      = game.juego.pathConfiguracion;
                (Application.Current.MainWindow as MainWindow).WrapPanel.Children.Add(gC);
            }
        }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();

            // Initialize the program on startup, setting all the info to its values.
            WrapPanel  = wrapMahepanel;
            StackPanel = StackMahePanel;

            // Loads the game stored on disk
            GameAdder gA = new GameAdder();

            gA.SearchForSavedGames();

            // Loads the hours into its positions
            SetHours();

            // Loads the user preferences
            List <Cuenta> defaultUser = new List <Cuenta>();
            string        folder      = System.IO.Path.GetDirectoryName(@"Data\userConfig\");
            string        extension   = "*.txt";

            string[] filesCache = Directory.GetFiles(folder, extension);
            bool     hasFile    = false;

            foreach (var file in filesCache)
            {
                if (file.Equals(@"Data\userConfig\preferences.txt"))
                {
                    hasFile = true;
                    break;
                }
            }
            // If user doesn't have preferences, creates ones.
            if (!hasFile)
            {
                Cuenta preferences = new Cuenta()
                {
                    preferencia = new Preferencia()
                    {
                        minimizarAlCerrar = 0, actualizacionesAutomaticas = 0, inicioAutomatico = 0
                    }
                };

                File.WriteAllText(@"Data\userConfig\preferences.txt", JsonConvert.SerializeObject(preferences));
            }

            //Draws the icon of the notification Windows menu.
            ni.Icon         = new System.Drawing.Icon(System.IO.Path.Combine(System.Windows.Forms.Application.StartupPath + @"\Data\", "Gamecher.ico"));
            ni.Visible      = true;
            ni.DoubleClick +=
                delegate(object sender, EventArgs args)
            {
                this.Show();
                this.WindowState = System.Windows.WindowState.Normal;
            };
            ni.ContextMenu = new System.Windows.Forms.ContextMenu();

            ni.ContextMenu.MenuItems.Add("Exit", (s, e) => { ni.Visible = false; Application.Current.Shutdown(); });
        }
Пример #4
0
        //Prompts the menu that allows the user to add games, automatically or manually
        private void AddGameClicked(object sender, MouseButtonEventArgs e)
        {
            /*GameCard gC = new GameCard();
             * gC.PlayButton.MouseUp += AddGameClicked;
             * wrapMahepanel.Children.Add(gC);*/

            this.Opacity = 0.9;
            this.Effect  = new BlurEffect();

            var gameAdder = new GameAdder()
            {
                Owner         = this,
                ShowInTaskbar = false
            };

            gameAdder.ShowDialog();
        }
Пример #5
0
 private void SearchFoldersForGames(List <string> fs)
 {
     using (BackgroundWorker bw = new BackgroundWorker())
     {
         bw.DoWork += delegate
         {
             foreach (string folder in fs)
             {
                 string[]  paths = GameSuggestions.GetGameFolders(folder);
                 GameAdder ga    = new GameAdder();
                 ga.DataReady += AdderOnDataReady;
                 ga.AddGames(paths);
             }
             workingProgress = WorkingProgress.BusyDoingNothing;
         };
         bw.RunWorkerAsync();
     }
 }
Пример #6
0
        public void SetManuallyAddedGame(string image, string gamePath)
        {
            string nombre = TextBoxNameOfManualGame.Text;
            Task   t      = Task.Factory.StartNew(() =>
            {
                if (nombre != null || !nombre.Equals(""))
                {
                    Configuracion config = new Configuracion()
                    {
                        pathExe = gamePath,
                        juego   = new Juego()
                        {
                            imageUrl = image,
                            nombre   = nombre
                        }
                    };
                    File.WriteAllText(@"Data\SavedGames\" + nombre + ".txt", JsonConvert.SerializeObject(config));

                    RegistoJuego register = new RegistoJuego()
                    {
                        cuenta = new Cuenta(),
                        juego  = new Juego()
                        {
                            imageUrl = image,
                            nombre   = nombre
                        }
                    };
                    File.WriteAllText(@"Data\GamesRegister\" + nombre + ".txt", JsonConvert.SerializeObject(register));
                }
            }).ContinueWith(tsk =>
            {
                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    GameAdder gA = new GameAdder();
                    gA.SearchForSavedGames();
                });
            });
        }
Пример #7
0
        private void AddAutodiscoveryFolderButton_Click(object sender, EventArgs e)
        {
            string t = AddAutoDiscoveryTextBox.Text;

            if (string.IsNullOrWhiteSpace(t))
            {
                return;
            }
            if (!Directory.Exists(t))
            {
                MessageBox.Show("Directory does not exist");
                return;
            }
            LocalDataManager ldm = new LocalDataManager();
            Config           cfg = ldm.LoadConfig();

            cfg.GamesFolders.Add(t);
            GameAdder ga = new GameAdder();

            ga.DataReady += AdderOnDataReady;
            ga.AddGames(GameSuggestions.GetGameFolders(t));
            AddAutoDiscoveryTextBox.Text = "";
        }