public void LoadCourseHandler(object sender, EventArgs e) { OpenFileDialog file = new OpenFileDialog(); file.InitialDirectory = Environment.CurrentDirectory; file.CheckFileExists = true; file.CheckPathExists = true; file.Multiselect = false; file.ValidateNames = true; file.Filter = "Course files (*.course)|*.course"; file.FileOk += (s, ee) => { try { ConcurrentWorkQueue.Enqueue(() => { Course c = new CourseXMLBackend(null).SetPath(file.FileName).Load(); this.registerCourse(c); }); } catch (InvalidCourseXMLException) { MessageBox.Show("Error loading course, the file might be corrupted.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }; file.ShowDialog(); }
public void FileDroppedHandler(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); IEnumerable <string> selection = files.Where((string s) => s.Contains(".course")); string x; if (selection.Count() > 0) { x = selection.First(); ConcurrentWorkQueue.Enqueue(() => { try { Course c = new CourseXMLBackend(null).SetPath(x).Load(); this.registerCourse(c); } catch (InvalidCourseXMLException) { MessageBox.Show("Error loading course, the file might be corrupted.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }); } }
public void StartLoadAutoHandler(object sender, EventArgs e) { // Load Course from autosave if (System.IO.File.Exists(Properties.Resources.SAVE_FILE_PATH)) { ConcurrentWorkQueue.Enqueue(() => { try { Course c = new CourseXMLBackend(null).SetPath(Properties.Resources.SAVE_FILE_PATH).Load(); this.registerCourse(c); return; } catch (InvalidCourseXMLException) { MessageBox.Show("Unable to load course, the file might be corrupted.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }); } else { MessageBox.Show("No autosave file present.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }