Esempio n. 1
0
 public MainWindow()
 {
     InitializeComponent();
     currentFile = new TaskFile(null, "");
 }
Esempio n. 2
0
        private void OpenMenuItemClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            fileDialog.Filter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";

            if (fileDialog.ShowDialog() == true)
            {
                try
                {
                    using (StreamReader reader = new StreamReader(fileDialog.OpenFile()))
                    {
                        String contents = reader.ReadToEnd();
                        String filePath = fileDialog.FileName;

                        currentFile = new TaskFile(filePath, contents);
                        UpdateDocumentContents();
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
        }