Beispiel #1
0
        public void Spiel_Starten_Test()
        {
            Spiel TestSpiel = new Spiel("Rechner", new DateTime(2017, 06, 14), @"C:\Windows\System32\calc.exe", "Action", "Microsoft", 0);

            GameController.Spiele.Add(TestSpiel);

            GameController.Spiel_Starten(TestSpiel);
            Process[] process = Process.GetProcessesByName("calc");

            Assert.AreNotEqual(process.Length, 0);
        }
Beispiel #2
0
 internal static List <Spiel> RemoveGame(Spiel s, List <Spiel> gameL)
 {
     if (s != null)
     {
         gameL.Remove(s);
         return(gameL);
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
        private void SpielHinzufügenButton_Click(object sender, EventArgs e)
        {
            SpielHinzufügenForm newGameDialog = new GameLauncher.SpielHinzufügenForm();

            this.Hide();

            newGameDialog.ShowDialog();
            Spiel s = newGameDialog.ReturnValue;

            this.Show();

            SpieleListBox.Items.Add(s);
        }
Beispiel #4
0
        internal static List <Spiel> SpielEntfernen(string Titel, string Publisher, List <Spiel> spieleListe)
        {
            Spiel zuLöschen = null;

            foreach (Spiel spiel in spieleListe)
            {
                if (spiel.titel == Titel && spiel.publisher == Publisher)
                {
                    zuLöschen = spiel;
                }
            }
            spieleListe.Remove(zuLöschen);
            return(spieleListe);
        }
Beispiel #5
0
        internal static void StartGame(Spiel s)
        {
            //Bsp: @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
            string[] pfadTeile = s.GetInstalationspfad.Split('/');
            //Bsp: "firefox.exe" möchte aber nur firefox
            string processname = pfadTeile.Last().Split('.').First();

            if (Process.GetProcessesByName(processname).Length > 0)
            {
                throw new GameAlreadyRunExeption();
            }

            Process.Start(s.GetInstalationspfad);
        }
Beispiel #6
0
 internal static void Spiel_Starten(Spiel Spiel)
 {
     if (!Spiele.Contains(Spiel))
     {
         throw new ArgumentOutOfRangeException("Das Spiel befindet sich nicht in der Verwaltung!");
     }
     else if (!File.Exists(Spiel.Pfad))
     {
         throw new ArgumentOutOfRangeException("Die angegebene Datei existiert nicht!");
     }
     else
     {
         Process.Start(Spiel.Pfad);
     }
 }
Beispiel #7
0
        internal static Spiel AddGame(string titel, DateTime instaldate, string pfad, string kat, string pub, int USK)
        {
            bool titelOk = StringArgumentsNotEmpty(titel);

            bool pfadOk = PfadVorhanden(pfad);

            bool katOk = StringArgumentsNotEmpty(kat);

            bool pubOk = StringArgumentsNotEmpty(pub);

            bool uskOk = USKPassend(USK);

            if (titelOk && pfadOk && katOk && pfadOk && uskOk)
            {
                Spiel s = new Spiel(titel, instaldate, pfad, kat, pub, USK);

                return(s);
            }
            else
            {
                throw new Exception();
            }
        }
 internal DetailDialog(Spiel s)
 {
     InitializeComponent();
     SelectedGame = s;
 }