/// <summary> /// Event on click button "btnFolder" /// </summary> /// <param name="sender">object</param> /// <param name="e">event</param> private void btnFolder_Click(object sender, RoutedEventArgs e) { //kill the thread childThread.Abort(); //open choose folder windows choosedirectory directoryClass = new choosedirectory(); directoryClass.ShowDialog(); directoryClass.Close(); //delete all displayed movies List <UIElement> delItems = new List <UIElement>(); IEnumerable <Image> covers = gridMovies.Children.OfType <Image>(); foreach (Image child in covers) { delItems.Add(child); } foreach (UIElement delitem in delItems) { gridMovies.Children.Remove(delitem); } //show loading loading.Visibility = Visibility.Visible; loading.Text = "We are finding your movies, please wait..."; //restart thread to display movie from the new path childThread = new Thread(displayMovies); childThread.SetApartmentState(ApartmentState.STA); childThread.Start(); }
/// <summary> /// Launch choose folder windows it it's the first launch and initialize DB /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MetroWindow_Loaded(object sender, RoutedEventArgs e) { // get movie path in config file string appdataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string folderPath = appdataPath + "/" + MainWindow.FOLDER_NAME; string filePath = folderPath + "/" + MainWindow.CONFIG_FILE_NAME; string moviePath = ""; string ogFileNamePath = folderPath + "/originalFileName.txt"; if (!File.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } if (!File.Exists(ogFileNamePath)) { var file = File.Create(ogFileNamePath); file.Close(); } choosedirectory directoryClass = new choosedirectory(); if (File.Exists(filePath)) { moviePath = directoryClass.GetPathConfig(filePath, "/config/path_movies"); } // open the second form if it's the first launch if (moviePath == "") { directoryClass.ShowDialog(); directoryClass.Close(); } dbhandler FMDb = new dbhandler(); }