Esempio n. 1
0
        public string SaveAs()
        {
            using (var saveDialog = new SaveFileDialog())
            {
                saveDialog.Filter = "(*.s)|*.s";
                if (saveDialog.ShowDialog() == DialogResult.OK)
                {
                    if (!String.IsNullOrEmpty(saveDialog.FileName))
                    {
                        using (var stream = saveDialog.OpenFile())
                            using (var writer = new StreamWriter(stream))
                            {
                                writer.Write(textEditorControl1.Document.TextContent);
                            }
                    }

                    _loadedFile = new ScrapeFile()
                    {
                        File = saveDialog.FileName
                    };
                    IsDirty = false;
                    return(Path.GetFileName(_loadedFile.File));
                }
            }

            return(null); //canceled
        }
Esempio n. 2
0
        public string Open()
        {
            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.CheckFileExists = true;
                openFileDialog.Filter          = "(*.s)|*.s";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    _loadedFile = new ScrapeFile()
                    {
                        File = openFileDialog.FileName
                    };
                    using (var stream = new FileStream(_loadedFile.File, FileMode.Open, FileAccess.Read))
                    {
                        textEditorControl1.LoadFile(_loadedFile.File, stream, true, true);
                    }

                    textEditorControl1.ActiveTextAreaControl.Document.DocumentChanged += OnDocumentChanged;
                    return(Path.GetFileName(_loadedFile.File));
                }
            }

            return(null); //they canceled.
        }
Esempio n. 3
0
        public string SaveAs()
        {
            using (var saveDialog = new SaveFileDialog())
            {
                saveDialog.Filter = "(*.s)|*.s";
                if (saveDialog.ShowDialog() == DialogResult.OK)
                {
                    if (!String.IsNullOrEmpty(saveDialog.FileName))
                    {
                        using (var stream = saveDialog.OpenFile())
                        using (var writer = new StreamWriter(stream))
                        {
                            writer.Write(textEditorControl1.Document.TextContent);
                        }
                    }

                    _loadedFile = new ScrapeFile() { File = saveDialog.FileName };
                    IsDirty = false;
                    return Path.GetFileName(_loadedFile.File);
                }
            }

            return null; //canceled
        }
Esempio n. 4
0
        public string Open()
        {
            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.CheckFileExists = true;
                openFileDialog.Filter = "(*.s)|*.s";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    _loadedFile = new ScrapeFile() { File = openFileDialog.FileName };
                    using (var stream = new FileStream(_loadedFile.File, FileMode.Open, FileAccess.Read))
                    {
                        textEditorControl1.LoadFile(_loadedFile.File, stream, true, true);
                    }

                    textEditorControl1.ActiveTextAreaControl.Document.DocumentChanged += OnDocumentChanged;
                    return Path.GetFileName(_loadedFile.File);
                }
            }

            return null; //they canceled.
        }