private void Form1_Load(object sender, EventArgs e) { fileName = Application.StartupPath + "\\filme.csv"; backupFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\filme_backup.csv"; picturePath = Application.StartupPath + @"\images\"; if (Environment.UserName.ToLower() == "patrick") { picturePath = @"D:\Patrick\Bilder\kamera\Amsterdam August 2012\"; } Point location = Properties.Settings.Default.Location; Size windowSize = Properties.Settings.Default.Size; this.Location = location; if (windowSize.Width != 0 && windowSize.Height != 0) { this.Height = windowSize.Height; this.Width = windowSize.Width; } try { mt = new mediaTools(fileName, picturePath, backupFileName); List <string> genres = mt.getGenreList(); genres.Sort(); foreach (string genre in genres) { if (genre.Length > 0) { /*cbcGenre.Items.Add(genre); * cbcGenreAdd.Items.Add(genre);*/ } } currentList = mt.getFilteredList(); fillGui(currentList); } catch (Exception ex) { MessageBox.Show("Beim Einlesen der Datei ist folgender Fehler aufgetreten:" + Environment.NewLine + ex.Message); } }
private void Form1_Load(object sender, EventArgs e) { if ((ModifierKeys & Keys.Shift) != 0) { File.Delete(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath); } fileName = Application.StartupPath + "\\filme.csv"; picturePath = Application.StartupPath + @"\images\"; if (Environment.UserName.ToLower() == "patrick") { picturePath = @"Q:\Patrick\Bilder\kamera\Amsterdam August 2012\"; } logging.Debug("Picturepath =" + picturePath); frm = new frmSettings(picturePath, fileName, "filme.csv"); changeHighlighting(btnFilterAll, true); changeHighlighting(btnShowAll, false); try { mt = new mediaTools(fileName, picturePath, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"filme_backup.csv", true); logging.Debug("mediatools Objekt erstellt"); currentList = mt.getAllEntrys(); movies = mt.getMovies(); series = mt.getSeries(); anime = mt.getAnimes(); logging.Debug("Listen für Film,Serie, Anime erstellt"); List <string> genreList = mt.getGenreList(); logging.Debug("genreList erstellt, Einträge:" + genreList.Count); foreach (string genre in genreList) { lbxGenre.Items.Add(genre); lbxGenreAdd.Items.Add(genre); } logging.Info("Alle Listen erfolgreich erstellt"); fillGui(currentList); } catch (FileNotFoundException) { MessageBox.Show("Die CSV Datei wurde nicht gefunden"); logging.Error("Die CSV Datei wurde nicht gefunden"); } catch (InvalidCastException ex) { MessageBox.Show("Die Datei enthält ungültige Werte. Der Fehler trat an folgender Stelle auf: " + ex.Data[0].ToString()); logging.Error("Die Datei enthält ungültige Werte. Der Fehler trat an folgender Stelle auf: " + ex.Data[0].ToString()); } catch (FormatException ex) { string exData = ""; foreach (DictionaryEntry de in ex.Data) { exData = de.Value.ToString(); } MessageBox.Show("Die Datei enthält ungültige Werte. Der Fehler trat an folgender Stelle auf: " + exData); logging.Error("Die Datei enthält ungültige Werte. Der Fehler trat an folgender Stelle auf: " + exData); } catch (Exception ex) { MessageBox.Show("Beim Laden des Programms trat folgender Fehler auf: " + ex.Message + Environment.NewLine + ex.StackTrace); logging.Error("Beim Programmstart trat ein Fehler auf", ex); } }
private void Form1_Load(object sender, EventArgs e) { fileName = Application.StartupPath + "\\filme.csv"; backupFileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\filme_backup.csv"; picturePath = Application.StartupPath + @"\images\"; if (Environment.UserName.ToLower() == "patrick") { picturePath = @"D:\Patrick\Bilder\kamera\Amsterdam August 2012\"; } Point location = Properties.Settings.Default.Location; Size windowSize = Properties.Settings.Default.Size; this.Location = location; if (windowSize.Width != 0 && windowSize.Height != 0) { this.Height = windowSize.Height; this.Width = windowSize.Width; } /*if (File.Exists(fileName)) * { * try * { * entrys = File.ReadAllLines(fileName).ToList(); * foreach (string entry in entrys) * { * string[] parts = entry.Split(';'); * Media m = new Media(freeId); * freeId++; * m.setName(parts[1]); * m.setLink(parts[2]); * m.setWatchDate(Convert.ToDateTime(parts[3])); * if (parts[3] != "") * { * m.setRating(Convert.ToInt32(parts[4])); * } * else * { * m.setRating(0); * } * if (parts[5] == "Film") * { * m.setType("Film"); * } * else if ((parts[5] == "Serie")) * { * m.setType("Serie"); * m.setParts(Convert.ToInt32(parts[6])); * } * else * { * m.setType("Anime"); * m.setParts(Convert.ToInt32(parts[6])); * } * * if (parts[7] != "") * { * m.setPicture(parts[7]); * } * if (parts.Count() > 8) //kompatibilität zur alten Liste ohne die Wunschliste/zuletzt geschaut * { * if (parts[8] != "") * { * m.setWishlist(Convert.ToBoolean(parts[8])); * } * if(parts.Count()>9) * { * * } * * } * content.Add(m); * } * * } * catch * { } * filteredList = content.FindAll(x=>x.wishList==false); * randomList.AddRange(filteredList); * randomList.Shuffle();*/ try { mt = new mediaTools(fileName, picturePath, backupFileName); List <string> genres = mt.getGenreList(); genres.Sort(); foreach (string genre in genres) { if (genre != "") { cbcGenre.Items.Add(genre); } } currentList = mt.getFilteredList(); fillGui(currentList); } catch (Exception ex) { MessageBox.Show("Beim Einlesen der Datei ist folgender Fehler aufgetreten:" + Environment.NewLine + ex.Message); } //} }