예제 #1
0
        private bool SaveAs()
        {
            var SaveDialog = new SaveOpenDialog();

            SaveDialog.FileDlgFileName   = Filename;
            SaveDialog.FileDlgDefaultExt = ".py";
            SaveDialog.FileDlgFilter     = "Python file (*.py)|*.py|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);
            File.WriteAllText(PotentialFilename, Content);

            Filename = PotentialFilename;
            IsDirty  = false;

            return(true);
        }
예제 #2
0
        private void menuitemFileOpen_Click(object sender, EventArgs e)
        {
            if (!EnsureWorkNotLost())
            {
                return;
            }

            var OpenDialog = new SaveOpenDialog();

            OpenDialog.FileDlgDefaultExt = ".py";
            OpenDialog.FileDlgFileName   = Filename;
            OpenDialog.FileDlgFilter     = "Python file (*.py)|*.py|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);
        }