Example #1
0
        private void NewFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FieldForm fieldForm = new FieldForm
            {
                MdiParent = this
            };

            fieldForm.Show();

            fieldForm.Text = "unnamed file";
        }
Example #2
0
        ///


        /// <summary>
        /// Load text from file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void LoadTextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter           = "txt file (*.txt)|*.txt|html file (*.html)|*.html",
                FilterIndex      = 1,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                FieldForm activeForm = new FieldForm();
                activeForm.MdiParent = this;
                using (StreamReader sr = new StreamReader(openFileDialog.FileName))
                {
                    activeForm.textField.Text = await sr.ReadToEndAsync();
                }
                activeForm.Text = openFileDialog.SafeFileName;
                activeForm.Show();
            }
        }