Esempio n. 1
0
        private void menuitemFileOpen_Click(object sender, EventArgs e)
        {
            if (!this.EnsureWorkNotLost())
            {
                return;
            }
            SaveOpenDialog OpenDialog = new SaveOpenDialog();

            OpenDialog.FileDlgDefaultExt = ".txt";
            OpenDialog.FileDlgFileName   = this.Filename;
            OpenDialog.FileDlgFilter     = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
            OpenDialog.FileDlgType       = FileDialogType.OpenFileDlg;
            OpenDialog.FileDlgCaption    = "Open";
            OpenDialog.FileDlgOkCaption  = "Open";
            if (OpenDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }
            this.Open(OpenDialog.MSDialog.FileName, OpenDialog.Encoding);
        }
Esempio n. 2
0
        private bool SaveAs()
        {
            SaveOpenDialog SaveDialog = new SaveOpenDialog();

            SaveDialog.FileDlgFileName   = this.Filename;
            SaveDialog.FileDlgDefaultExt = ".txt";
            SaveDialog.FileDlgFilter     = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
            SaveDialog.Encoding          = this._encoding;
            SaveDialog.FileDlgCaption    = "Save";
            SaveDialog.FileDlgOkCaption  = "Save";
            if (SaveDialog.ShowDialog(this) != DialogResult.OK)
            {
                return(false);
            }
            string PotentialFilename = SaveDialog.MSDialog.FileName;

            this._encoding = SaveDialog.Encoding;
            File.WriteAllText(PotentialFilename, this.Content, this._encoding);
            this.Filename = PotentialFilename;
            this.IsDirty  = false;
            return(true);
        }