Ejemplo n.º 1
0
        public override void Save(string fileName)
        {
            OnSaving(EventArgs.Empty);
            watcher.Disable();

            if (!textAreaControl.CanSaveWithCurrentEncoding())
            {
                if (MessageService.AskQuestion("The file cannot be saved with the current encoding " +
                                               textAreaControl.Encoding.EncodingName + " without losing data." +
                                               "\nDo you want to save it using UTF-8 instead?"))
                {
                    textAreaControl.Encoding = System.Text.Encoding.UTF8;
                }
            }

            textAreaControl.SaveFile(fileName);
            if (fileName != this.FileName)
            {
                ParserService.ClearParseInformation(this.FileName ?? this.UntitledName);
                FileName = fileName;
                ParserService.ParseViewContent(this);
            }
            TitleName = Path.GetFileName(fileName);
            IsDirty   = false;

            watcher.SetWatcher(this.FileName);
            OnSaved(new SaveEventArgs(true));
        }
        public override void Save(OpenedFile file, Stream stream)
        {
            if (file != PrimaryFile)
            {
                throw new ArgumentException("file != PrimaryFile");
            }

            if (!textEditorControl.CanSaveWithCurrentEncoding())
            {
                if (MessageService.AskQuestion("The file cannot be saved with the current encoding " +
                                               textEditorControl.Encoding.EncodingName + " without losing data." +
                                               "\nDo you want to save it using UTF-8 instead?"))
                {
                    textEditorControl.Encoding = System.Text.Encoding.UTF8;
                }
            }

            textEditorControl.SaveFile(stream);
        }