Пример #1
0
        private bool SaveAs()
        {
            var SaveDialog = new SaveOpenDialog();

            SaveDialog.FileDlgFileName   = Filename;
            SaveDialog.FileDlgDefaultExt = ".txt";
            SaveDialog.FileDlgFilter     = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
            SaveDialog.Encoding          = _encoding;
            SaveDialog.FileDlgCaption    = "Save";
            SaveDialog.FileDlgOkCaption  = "Save";

            if (SaveDialog.ShowDialog(this) != DialogResult.OK)
            {
                return(false);
            }

            var PotentialFilename = SaveDialog.MSDialog.FileName;

            _encoding = SaveDialog.Encoding;
            File.WriteAllText(PotentialFilename, Content, _encoding);

            Filename = PotentialFilename;
            IsDirty  = false;

            return(true);
        }
Пример #2
0
        //File.Open
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!EnsureWorkNotLost())
            {
                return;
            }

            var OpenDialog = new SaveOpenDialog();

            OpenDialog.FileDlgDefaultExt = ".txt";
            OpenDialog.FileDlgFileName   = Filename;
            OpenDialog.FileDlgFilter     = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
            OpenDialog.FileDlgType       = Win32Types.FileDialogType.OpenFileDlg;
            OpenDialog.FileDlgCaption    = "Open";
            OpenDialog.FileDlgOkCaption  = "Open";

            if (OpenDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            Open(OpenDialog.MSDialog.FileName, OpenDialog.Encoding);
        }
Пример #3
0
        private bool SaveAs()
        {
            var SaveDialog = new SaveOpenDialog();
            SaveDialog.FileDlgFileName = Filename;
            SaveDialog.FileDlgDefaultExt = ".txt";
            SaveDialog.FileDlgFilter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
            SaveDialog.Encoding = _encoding;
            SaveDialog.FileDlgCaption = "Save";
            SaveDialog.FileDlgOkCaption = "Save";

            if (SaveDialog.ShowDialog(this) != DialogResult.OK) return false;

            var PotentialFilename = SaveDialog.MSDialog.FileName;

            _encoding = SaveDialog.Encoding;
            File.WriteAllText(PotentialFilename, Content, _encoding);

            Filename = PotentialFilename;
            IsDirty = false;

            return true;
        }
Пример #4
0
        private void menuitemFileOpen_Click(object sender, EventArgs e)
        {
            if (!EnsureWorkNotLost()) return;

            var OpenDialog = new SaveOpenDialog();
            OpenDialog.FileDlgDefaultExt = ".txt";
            OpenDialog.FileDlgFileName = Filename;
            OpenDialog.FileDlgFilter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*";
            OpenDialog.FileDlgType = Win32Types.FileDialogType.OpenFileDlg;
            OpenDialog.FileDlgCaption = "Open";
            OpenDialog.FileDlgOkCaption = "Open";

            if (OpenDialog.ShowDialog(this) != DialogResult.OK) return;

            Open(OpenDialog.MSDialog.FileName, OpenDialog.Encoding);
        }