コード例 #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
ファイル: Main.cs プロジェクト: mumu/NotepadClone
        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
ファイル: Main.cs プロジェクト: mumu/NotepadClone
        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);
        }