public void ImportFile(string filePath) { LastImportedFile = ""; try { if (string.IsNullOrEmpty(filePath)) { return; } FileInfo fileInfo = new FileInfo(filePath); importedFileName = fileInfo.Name; using (StreamReader sr = new StreamReader(filePath, Encoding.Default)) ImportedText = new ReadOnlyTypingBuffer(sr.ReadToEnd(), userSettings.VisibleNewlines, userSettings.RemoveEndOfLineSpaces, userSettings.RemoveMultipleWhitespace); LastImportedFile = fileInfo.FullName; lblStatusBarMain.Text = "Imported"; stopwatch.Reset(); rightAfterImport = true; PracticeMode = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Typist", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public TypistForm(string filePath) { InitializeComponent(); loadWindowPosition(); loadTypingFont(); loadUserSettings(); initializeTypingBox(); initializeContextMenuStrip(); initializeSettingsDialog(); ImportedText = new ReadOnlyTypingBuffer("", userSettings.VisibleNewlines, userSettings.RemoveEndOfLineSpaces, userSettings.RemoveMultipleWhitespace); PracticeMode = false; ImportFile(!string.IsNullOrEmpty(filePath) ? filePath : LastImportedFile); loadStatisticsMode(); }